Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

954
Views
Can't access Postgres running with docker-compose from WebStorm (JetBrains)

I have the following docker-compose.yml:

version: '3.7'

services:
  postgres-service:
    image: postgres:12.3
    env_file:
      - .env
    ports:
      - '5432:5432'
    volumes:
      - /postgres/data/

This is my .env:

POSTGRES_USER=app_postgres_user
POSTGRES_PASSWORD=foobar
POSTGRES_DB=app_database

I know postgres-service is working because I connect manually to the service and it works with following commands:

docker-compose run postgres-service bash # connect to postgres-service
psql --host=postgres-service --username=app_postgres_user --dbname=app_database

But when I try to connect from within "Webstorm > Database" I get this error:

The connection attempt failed.
java.net.UnknownHostException: postgres-service.

Screenshot: enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If Webstorm is running on the same host as the container, replace postgres-service with localhost.

If it is running elsewhere, replace postgres-service with the IP address of the docker host machine where the container resides.

I used your docker-compose and connected with DBeaver with these settings:

enter image description here

Your postgres container resides in a virtual network (e.g.: 172.17.0.0/16). By default there is no route from your machine to that network.

When you use

ports:
      - 'src:dest'

...in your docker-compose.yml file, a DNAT rule is created from your host:src to the container:dest and that's the reason of using localhost:src or the IP address of the docker host.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!