[POSTGRES - SOLVED] Fail to connect Postgresql container


I’m very new to docker. I’ve been searching for my answer but all i found did not worked.

I have installed docker on my local server (Synology) and ran two linked containers - one for nodejs, the other for postgresql.

I can access in my terminal, with my local IP or my public IP to the postgresql container and create a new db and so on… by accessing my server in ssh, run an instance in my docker container and log with psql.

Now, i would like to access my database with an app like PGadmin or Tableplus on my laptop but it doesn’t work. I’have published the container on my 5431 port and set a POSTGRES_PASSWORD in my environment but I always get this message when i try to connect :

“server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.”

To be honest i don’t know which IP adress i should use so tried with all IP i know. When i type docker ps it returns :>5431/tcp

When I type docker inspect my-postgres-container, it returns :

“5431/tcp”: [
“HostIp”: “”,
“HostPort”: “5431”
“Gateway”: “”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“IPAddress”: “”,

Why it doesn’t work ?

Thank you for you help

ok… this means the container port 5431 is mapped to the host port 5431.

so that means some application on another machine (your laptop) should be able to access via

“IPAddress”: “”,

means that the container ip address is set to, but it can only be reached directly from the machine where docker run was issued.

see here for solving the connection reset problem

postgres, mysql and mongo all default to ONLY allow connections from the SAME MACHINE

1 Like

EDIT : Thank you for your answer @sdetweil. I followed the instructions of this topic. I entered in the conf file but it was already written that all IP (v4) were listned (i had to install nano also) :

listen_adress = ‘*’

I also uncomment the default port and change it for 5431. Now it’s fully working, i use this adress :

my.server.adress : 5431

I’ve also been able to access my postgres container by creating a new container with the pgadmin’s image on the same machine and in the same docker network.

Thank you !

what is that address? it is not the container

and it is not the docker host machine ip address

Just edited my message :D. I made a mistake in my local adress in Tableplus, now it’s working. :ok_hand:
And it also working outside of my network, that’s perfect. I can use Table Plus and connect to my database from everywhere with my laptop.

Port mappings, baby!

@qvdp Hello, on which file did you find this line my.server.adress : 5431?

is it on pg_hba.conf or postgressql.conf ?