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.