Dennis
Dennis

Reputation: 1018

Postgres service started, but can't connect. Nothing listening on port 5432

I don't know how this happened, but my postgres server (9.6.2) has stopped working locally. I seem to be able to start it up, and stop it using: brew services start postgresql and brew services start postgresql but when I try to connect using psql I get this error:

psql: could not connect to server: No such file or directory    Is the
server running locally and accepting    connections on Unix domain
socket "/tmp/.s.PGSQL.5432"?

When I try to see if anything is listening on port 5432 using lsof -i :5432 I get nothing.

Looked at other posts that say check the pg_hba.conf file, which I did, but doesn't seem to be the problem.

Upvotes: 2

Views: 890

Answers (1)

Dennis
Dennis

Reputation: 1018

I ended up reinstalling postgres via homebrew. That by itself didn't do enough. I had to kill my data directory to get this to work (i.e. rm -rf /path/to/my/data/directory) and then rebuild it using initdb.

This solution obviously only works if you don't care about keeping your data (in my case, it was just data for my dev environment, so I didn't). If you do want to save a copy of your data, I you'd have to come up with something else.

Upvotes: 1

Related Questions