简体   繁体   中英

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.

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.

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 !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM