symlink
symlink

Reputation: 12209

pgAdmin and PostgreSQL: can't connect to server

I just installed PostgreSQL on Snow Leopard and can't connect to the database server via pgAdmin 3.

I'm on my local machine, however I keep getting this error:

Could not connect to server: connection refused. Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5423?

I'm a bit of a noob when it comes to Postgres, so I'm not really sure what the problem is.

I can, however, log in through the command line, via psql -U postgres, and start and stop the server successfully.

Any help would be much appreciated.

Upvotes: 2

Views: 17074

Answers (2)

Craig Ringer
Craig Ringer

Reputation: 324265

UPDATE: Tuan Dang spotted it. I'll leave this answer in place in case it helps someone else for whom the issue isn't quite the same.

Since you can connect via the command line, run:

SHOW port;

from psql. You'll probably see that the port is not 5432. You need to connect to the port PostgreSQL is actually running on from your application.

It's also possible that it just isn't listening on TCP/IP. Run:

SHOW listen_addresses;

to see what it's listening for.

The reason you can connect via the command line is likely to be because the command line psql you're using is connecting over a unix socket (since you didn't specify a host) and your app is connecting via tcp/ip.

Upvotes: 3

Tuna
Tuna

Reputation: 2995

The error message pointed out that you tried to connect to server on port 5423. However, postgres server listens on 5432 by default.

From your above comment (SHOW port; gives me "5432"), I think you need to change the port to 5432!

Upvotes: 2

Related Questions