Glory to Russia
Glory to Russia

Reputation: 18712

Why can't I connect to a Postgres database?

I've installed and started a Postgres 9.1 instance on a DigitalOcean droplet.

When I try to connect to it using my PgAdmin III client (settings see below), I get the message that the server is not listening at the specified port.

Connection settings

The output netstat -na at the server side contains a line, which indicates that the server is actually listening on port 5432.

netstat

Why can't I connect to that server?

Upvotes: 0

Views: 2101

Answers (2)

Danish Khakwani
Danish Khakwani

Reputation: 353

You have probably configured following two files
pg_hba.conf
host all all 0.0.0.0/0 md5
postgresql.conf
listen_addresses='*'

You have to check if the port 5432 is open: http://www.yougetsignal.com/tools/open-ports/

Linux: If it's not then add a rule to your iptables:
iptables -A INPUT -s 0/0 -p tcp --dport 5432 -j ACCEPT

0/0: If you want anybody to access it.
You can change it to a specific ip address or range of ip addresses

Windows: Configure firewall

Upvotes: 2

user1247058
user1247058

Reputation:

You're only listening on localhost (127.0.0.1), so only connections from the same machine will be accepted. Tell Postgres to listen on 0.0.0.0, or, for more security, look into SSH tunnels.

Upvotes: 0

Related Questions