This is a quick post around how to resolve the following error while running Rails locally. Often I recieve this error after an improper shutdown (i.e. crash) of my computer. When I boot my project back up I’m greeted with this:
connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?
I’m currently using macOS Catalina (10.15.7) and using Homebrew for my Postgres management, so this solution will be for that environment. To resolve, run the following commands:
cd /usr/local/var/postgres mv postmaster.pid ~/Desktop brew services restart postgresql
Here’s the same commands, but as a fancy one-liner:
mv /usr/local/var/postgres/postmaster.pid ~/Desktop && brew services restart postgresql
If that resolved your problem, you can delete the
postmaster.pid on your Desktop.
Happy development! 🥳