khezen / compose-postgres

Postgresql & pgadmin4 powered by compose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pgAdmin does not connect to postgres

Cage-e opened this issue · comments

I up this compose and all is good except when I add a new server in pgAdmin to connect to postgres, it says:
Unable to connect to server:

could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Address not available
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?

my new server:
Host: localhost
port: 5432

I can connect through local pgAdmin installation though, but not the one on localhost:5050.

Is it only me having this problem? Am I missing something?

Hi,

Can you provide your docker version, docker-compose version and operating system?
Can you ping localhost:5432 to check if something it is running something?

Otherwise it is probably because, for security reasons, a PostgreSQL server “out of the box” doesn’t listen on TCP/IP ports.Instead, it has to be enabled to listen for TCP/IP requests.

This can be done by adding tcpip = true to the postgresql.conf file for Versions 7.3.x and 7.4.x, or listen_addresses=’*’ for Version 8.0.x and above; this will make the server accept connections on any IP interface.

ref: https://www.pgadmin.org/docs/pgadmin4/dev/connect_error.html

I have the same issue, offcourse changing postgres conf in a docker container is a pain in the ass, someone managed to do it ?

Thanks all

Some hack that worked for me :
docker inspect container_name_or_hah
Then find your local ip address that is bind to the postgres container and you use it in the pgAdmin configuration

Ok, I had the above trouble, and saw this screen:
image

So, I ran docker inspect postgres_container

I got a long stream of JSON as a result, but half way down was config block. The first entry in this was `"Hostname": "4765bite0me3112"

I entered 4765bite0me3112 as the Host name/address in the dialog, and it connected immediately.

You can also use postgres as host name since it is the service name in the compose file.
Other services(for instance pgadmin4) in the same network will resolve it.

mac
hostname: host.docker.internal

mac
hostname: host.docker.internal

Windows works too, thank you

commented

if you closed the pgadmin from the task manager it will be a problem after rerun it again so if you did that you just need to do the next steps:
1-go to search windows write "services" click enter
it will open a services window than
2-search for "postgresql"
3-right click and again click in proprieties
4- and last one click start

run again your pgadmin and it will work
good luck

So, I ran docker inspect postgres_container
I got a long stream of JSON as a result, but half way down was config block. The first entry in this was "Hostname": "4765bite0me3112" I entered 4765bite0me3112as theHost name/address` in the dialog, and it connected immediately.

Yes, hashed hostname worked for me too. This is very confusing though.

I also use adminer in the same way (as a docker container to access the postgres docker container) and it is able to figure this out without any user input. Worth adopting that approach as a default

You can also use postgres as host name since it is the service name in the compose file.
Other services(for instance pgadmin4) in the same network will resolve it.

Didn't work for me:

**Unable to connect to server:

could not translate host name "93ed5fee89db" to address: nodename nor servname provided, or not known**

Didn't work for me

Ok, I had the above trouble, and saw this screen: image

So, I ran docker inspect postgres_container

I got a long stream of JSON as a result, but half way down was config block. The first entry in this was `"Hostname": "4765bite0me3112"

I entered 4765bite0me3112 as the Host name/address in the dialog, and it connected immediately.

Need to put docker container name in place of localhost:
image

I up this compose and all is good except when I add a new server in pgAdmin to connect to postgres, it says: Unable to connect to server:

could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Address not available Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

my new server: Host: localhost port: 5432

I can connect through local pgAdmin installation though, but not the one on localhost:5050.

Is it only me having this problem? Am I missing something?

You need to put in place of localhost, your docker container name:
image

oh it works for me

if you closed the pgadmin from the task manager it will be a problem after rerun it again so if you did that you just need to do the next steps: 1-go to search windows write "services" click enter it will open a services window than 2-search for "postgresql" 3-right click and again click in proprieties 4- and last one click start

run again your pgadmin and it will work good luck

Thank you!

It worked for me! (running in Windows)

I up this compose and all is good except when I add a new server in pgAdmin to connect to postgres, it says: Unable to connect to server:
could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Address not available Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
my new server: Host: localhost port: 5432
I can connect through local pgAdmin installation though, but not the one on localhost:5050.
Is it only me having this problem? Am I missing something?

You need to put in place of localhost, your docker container name: image

this is the solution man thank glob u made that clear i was writing localhost on my wsl container

an entire day spent trying to solve this. I think packing it up and operating from spreadsheets will be faster.