Created
November 27, 2015 01:42
-
-
Save hoasung01/48796642d7bf75da5bef to your computer and use it in GitHub Desktop.
PG::ConnectionBad - could not connect to server: Connection refused
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It could be as simple as a stale PID file. It could be failing silently because your computer didn't complete the shutdown process completely which means postgres didn't delete the PID (process id) file. The PID file is used by postgres to make sure only one instance of the server is running at a time. So when it goes to start again, it fails because there is already a PID file which tells postgres that another instance of the server was started (even though it isn't running, it just didn't get to shutdown and delete the PID). | |
To fix it remove/rename the PID file. Find the postgres data directory. On a MAC using homebrew it is /usr/local/var/postgres/, 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. | |
launchctl unload homebrew.mxcl.postgresql.plist | |
launchctl load -w homebrew.mxcl.postgresql.plist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment