Home:ALL Converter>Psql Docker: could not connect to server: No such file or directory

Psql Docker: could not connect to server: No such file or directory

Ask Time:2019-05-01T10:51:03         Author:spacegoing

Json Formatter

I created a container using following command:

docker run -itd --name jkdb -e POSTGRES_PASSWORD=123 -v /home/lchang/jkrug/data:/var/lib/postgresql/data -p 5532:5432 -d postgres

I checked in container and psql does listen to 5432 in container.

However, when I try to connect from my host by following command, I got an error:

psql -p 5532 -U postgres
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5532"?

I searched many posts but none of them is same with my case. Any idea? Thanks!

Author:spacegoing,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55931067/psql-docker-could-not-connect-to-server-no-such-file-or-directory
spacegoing :

It does not make any sense but after I specify the host IP is 0.0.0.0 I can connect to docker.",
2019-05-03T06:16:22
yy