Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Connect to Postgres on Docker Container via pgAdmin

I have pulled postgres image with docker pull postgres. I have also tried to run image from https://docs.docker.com/examples/postgresql_service/

I run them with -p 5432:5432 option, but could not connect with pgAdmin. It gave me timeout when I tried to connect via localhost:5432. Examples I found on the internet say just use -p. I did, and it does not work. Also security settings at least from example above are very permissive. Any suggestions?

like image 390
Alua K Avatar asked Oct 04 '15 20:10

Alua K


People also ask

How do I connect to a postgres database in PgAdmin?

To access a database in the pgAdmin browser, expand Servers, the DB instance, and Databases. Choose the DB instance's database name. To open a panel where you can enter SQL commands, choose Tools, Query Tool.

Can't connect to server connection refused PgAdmin?

If the error message returns, make sure that you have the correct password, that you are authorized to access the server, and that the access has been correctly configured in the server's postgresql. conf configuration file.


1 Answers

Depending on how you ran Docker, this is not likely to work. The Docker Daemon runs in a virtual machine on OS X, which means you actually need to connect to that IP address (rather than localhost). To find that IP address, type the following:

docker-machine ip default

The IP you get back will tell you the IP to connect to.

like image 118
aronchick Avatar answered Nov 11 '22 15:11

aronchick