Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres server not listening

I'm trying to connect with my client (Macbook Pro) to a Postgres Database located in another PC in the same network (Ubuntu) I can see the database from the host with pgAdmin, connecting to localhost, but I can't see from the client.

I've allowed all the connections in pg_hba.conf and postgresql.conf

I'm trying to connect from the client through pgAdmin to the IP server where the database is stored (192.168.1.34) and port 5432

enter image description here And I get this error enter image description here What do I'm doing wrong?

Am I missing something

After reading suggestions, I can say: On the ubuntu machine (home test server) I have no firewall. Postgres is running.

I've tried from the ubuntu console to access to the database: psql -h 127.0.0.1 mydatabase postgres and can connect (which means that the server is running and username is ok) But if I try to access the same database, from the same machine, changing localhost with the IP, I can not connect. Should not be psql -h 127.0.0.1 mydatabase postgres the same as psql -h 192.168.1.34 mydatabase postgres when I connect from the server?

Maybe is in loopback, as Alain suggested?

like image 737
Pablo Pardo Avatar asked Jun 27 '15 17:06

Pablo Pardo


People also ask

Is Postgres running on port 5432?

The PostgreSQL database service is available on localhost and the default PostgreSQL port is 5432 . A default user ( hosting-db ) and database ( postgres ) exist so you can quickly test your connection and perform management tasks.

Could not connect to Postgres server connection refused?

“Could not connect to server: Connection refused” To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql. If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections.

How do I check if port 5432 is open Linux?

If you are trying to connect to a Postgres instance on the same host as your terminal, you can run lsof -p :5432 which will show which, if any, processes are listening on that port. The postgres process should be connected there. You can also look at the listen_address and port value in your postgresql.


1 Answers

You have allow postgresql to accept request from outside network. To do that you have to change two files located at /etc/postgresql/{version_code}/main First one is pg_hba.conf, open and

change host all all ::1/128 md5 to host all all 0.0.0.0/0 md5

Second one is postgresql.conf, open and

change listen_address = 'localhost' to listen_address = '*'

Now restart the postgre server.

like image 157
Shalauddin Ahamad Shuza Avatar answered Oct 24 '22 08:10

Shalauddin Ahamad Shuza