2

I have Postgresql running in a Docker container with port 5432 is exposed.

$ docker ps -a
IMAGE               STATUS                    PORTS                    NAMES
postgres:9.6        Up 32 minutes (healthy)   0.0.0.0:5432->5432/tcp   service_postgresql_1

My IP address in LAN:

$ ifconfig | grep inet

...
inet 192.84.4.108 netmask 0xffffff00 broadcast 192.84.4.255
...

My /etc/hosts file:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

My OS: macOS High Sierra

My problems: Failed to connect to Postgres with Host = localhost

Host = 192.84.4.108 -> Success

Host = localhost -> Fail

I use both pgAdmin 4 and IntelliJ IDEA and the results are the same.

Please let me know the cause if you faced a similar problem. Thanks.

Hung Vi
  • 490
  • 4
  • 16

1 Answers1

0

It seems you're using Docker toolbox

From docs :

Docker Desktop for Mac is available for free. Requires Apple Mac OS Sierra 10.12 or above. Download Docker Toolbox for previous OS versions.

Which version do you have? If you've installed Docker toolbox, that's a normal behavior

k-lusine
  • 397
  • 4
  • 11