By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,529 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,529 IT Pros & Developers. It's quick & easy.

psql won't connect, though other clients are OK

P: 2
Hello -
I'm running PG 8.1 on Windows XP.
I've installed the server to run as a service.

The psql command fails to connect to the server, although I can connect with other clients.

When I enter psql -d mydb -h localhost -U admin
I get the following response:
psql: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432?

However, with the following steps I can prove that the server is indeed running on localhost and listening on 5432.

First, I run pgAdmin3 and connect to the server. The properties panel shows me that I'm connected to the server via localhost port 5432.
Next, with pgAdmin3 running, I do a netstat and get the following result:

TCP jma:1500 localhost:5432 ESTABLISHED
TCP jma:1502 localhost:5432 ESTABLISHED
TCP jma:5432 localhost:1500 ESTABLISHED
TCP jma:5432 localhost:1502 ESTABLISHED

But if I now run psql, I get the same error message as before.

My postgresql.conf file has the following line:
listen_addresses = 'localhost'
I also tried changed 'localhost' to '*', but the result was the same.

If I leave off the -h option on the psql command, the message is a little different. It says (in part):
... Is the server running on host "???" ...

I've searched the threads in this forum for psql problems and found a few. But not exactly this one.

Can anyone tell me why psql won't connect?
May 16 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 534
We may need to look at postgresql.conf and pg_hba.conf, but before we get to it, are you running a firewall on this computer?
If yes, could you try to disable it for a minute and run psql again?
May 17 '07 #2

P: 2
Thank you. It was my Zone Alarm firewall. I turned it off, and it worked.

I originally thought that the firewall was not the problem, because it was letting the other clients connect.

Strange thing though --- when I turned ZA back on, it let psql run. I found that it had created a rule saying psql was OK. bizarre.
May 22 '07 #3

Expert 100+
P: 534
Yes, ZoneAlarm can be tricky. If I remember correctly there could be different ways to allow your programs to work, you can open the specific port#, or you can designate a certain app as trusted... Anyway, the good thing is you got it working!
May 22 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.