0

I know for sure postgresql is running (checked with ps ax), but when I install pgAdmin and try to make a server connection to localhost I get this error:

Server doesn't listen
The server doesn't accept connections: the connection library reports 
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
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 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting TCP/IP connections on port 5432? 

Any help?

4
  • What is netstat -tulpn saying where postgres is listen on?
    – frlan
    May 27, 2014 at 11:52
  • netstat: n: unknown or uninstrumented protocol May 27, 2014 at 11:53
  • Try: netstat -nlp tcp | grep postgres. Source.. Are you aware that localhost is not a "local" connection type in pg_haba.conf on UNIX installations? More here. Provide settings in your pg_hba.conf file, if that does not clear the smoke. May 27, 2014 at 22:42
  • PostgreSQL probably isn't listening on port 5432, but some other port. Check port in postgresql.conf or look for listening ports with netstat or lsof. You're on OS X, which has different tools, so I can't give exact command lines. May 28, 2014 at 2:52

2 Answers 2

1

Postgresql, just as most databases, can be accessed locally (on the local machine) and on TCP/IP, from remote machines. There is a common phenomenon that a database is configured by default for local connections.

The local connections can happen

  • on unix sockets, these are very like TCP ports, but they have a filesystem path instead of a port number. In case of PostgreSQL, the commons settings are 5432 for the TCP port and /var/run/postgresql/.s.PGSQL.5432.
  • On TCP ports, which is by default 127.0.0.1:5432, and is often by default turned off. To turn it on, specify port = '5432' in postgresql.conf.

Most clients - php postgresql module, or the command line psql command - connecting the local server on unix sockets by default.

pgAdmin is a special thing, it wants to connect only to TCP ports, even if it runs on a localhost. It doesn't mean anything on your system were bad, this tool was simply so written, that it can use only TCP even for localhost administering.

You had to enable the TCP port listening in postgresql config file pg_hba.conf. The following line will be probably okay:

host all all 127.0.0.0/8 trust

The official documentation for this pg_hba.conf can you find here, and a short tutorial to enable the localhost networking can you find here.

If it don't work or you want better answer, it could help a lot if you extended your question with your actual pg_hba.conf.

Good luck!

0

Locally, no TCP needed. You need to find the correct Unix domain socket file and call it by adding its path with the "-h" parameter - rather than adding a hostname or IP address.

I found out to get connection to Calendar and Contacts database of El Capitan and Sierra Server.

https://discussions.apple.com/thread/8164982

Maybe someone have some experiences with the record structure of the Contacts database?!

Regards from Hamburg

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.