5

I have some, albeit limited, experience with MySQL and MongoDB (both running fine on server) but having trouble with Postgres and find the documentation lacking for newbies, like myself.

Postgres is installed and running. But I cannot connect from a client.

pg_hba.conf looks like this (I added the last line):

# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
## Added by me
host all all 10.0.1.201/32 trust

Now if I go to the client 10.0.1.201 and try to psql -h server.domain.com I get an error:

psql: could not connect to server: Connection refused
 Is the server running on host "server.domain.com" (10.0.1.38) and accepting
 TCP/IP connections on port 5432?

ssh authorized_keys are setup for this client <-> server connection. There is also Kerberos as an option. Seems I might have too many options here? Not quite sure how to troubleshoot this? I can verify Postgres IS running.

meltemi$ sudo lsof -i -P | grep -i ':5432'
meltemi$

leads me to believe maybe it's not listening?

ideas?

asked Mar 1, 2012 at 2:50
0

4 Answers 4

6

The next thing to check is probably that you have a line in your postgresql.conf that looks like this:

listen_addresses = '*'

You will have to restart after changing that line. Otherwise your pg_hba.conf looks fine.

Good luck! Getting started is a big hurdle, but once you get through it, you will probably find that compared to MySQL things are a lot simpler and more consistent.

answered Mar 1, 2012 at 4:42
1
  • This is a common gotcha to initial setups. It still gets me. +1 !!! Commented Mar 1, 2012 at 19:11
1

It could be your firewall? Have you added a rule in iptables for port 5432?

I used this guide which was quite helpful. Scroll down and you will find it. http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html

answered Mar 1, 2012 at 5:19
1
  • no firewall between this client & the server (all on a private & protected LAN). Commented Mar 1, 2012 at 6:40
1

Does ps -ef | grep postgres find postgres processes running?

Along with @Daniel Lyons' suggestion to look at postgresql.conf for the IP address that it's listening on, remember to uncomment the port.

Have you tried psql as a database user on the database server to verify that you can connect to the postgres service?

answered Mar 1, 2012 at 19:00
1

It's probably

listen_addresses = '*'

as @Daniel already posted. One other explanation could be that you configured a different port than the standard 5432. That's usually the line right below in postgresql.conf (but can be anywhere in the file). For instance:

port = 5433
answered Mar 4, 2012 at 13:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.