Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Innarticles/ff65feb18d19f3dc17f9bf6ef2f06832 to your computer and use it in GitHub Desktop.
Save Innarticles/ff65feb18d19f3dc17f9bf6ef2f06832 to your computer and use it in GitHub Desktop.
To fix it remove/rename the PID file. Find the postgres data directory. On macOS using homebrew it is in /usr/local/var/postgres/, or /usr/local/var/log/ other systems it might be /usr/var/postgres/. To make sure this is the problem, look at the log file (server.log).
To fix it remove/rename the PID file. Find the postgres data directory. On macOS using homebrew it is in /usr/local/var/postgres/, or /usr/local/var/log/ other systems it might be /usr/var/postgres/.
To make sure this is the problem, look at the log file (server.log). On the last lines you will see:
```
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 347) running in data directory "/usr/local/var/postgres"?
```
If so, `rm postmaster.pid`
Restart your server. On a mac using launchctl (with homebrew) the following commands will restart the server.
```brew services restart postgresql```
From https://stackoverflow.com/questions/19828385/pgconnectionbad-could-not-connect-to-server-connection-refused
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment