Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 596
spacegoing Avatar asked May 01 '19 02:05

spacegoing


1 Answers

It does not make any sense but after I specify the host IP is 0.0.0.0 I can connect to docker.

like image 187
spacegoing Avatar answered Oct 25 '22 18:10

spacegoing