Last active
January 18, 2017 10:49
-
-
Save RemiDuvoux/0f7a1aeb79f04a6f18b3ce672c292fdd to your computer and use it in GitHub Desktop.
This file contains 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
If your computer was shut down in an unexpected way, an error could occur when launching your server | |
problem while using OauthProvider model: | |
'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? | |
Solution from http://stackoverflow.com/questions/19828385/pgconnectionbad-could-not-connect-to-server-connection-refused | |
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). | |
1. Find the postgres data directory. On a MAC using homebrew it is /usr/local/var/postgres/, other systems it might be /usr/var/postgres/. | |
2. 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"? | |
3. If so, rm postmaster.pid | |
4. Restart your server. Should be working now. | |
Conclusion: Always be careful when shutting down your computer, and never run out of battery with a Rails server running :D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment