At home, I’m a Linux user but at work most companies use Mac for engineers. It’s been a couple years since I’ve used Mac so I’m learning my way back around it along with Homebrew. One issue I ran into the other day was postgresql service not starting sucessfully. No amount of brew services restart postgresql would fix it. Turns out to be a pretty simple fix.

I first noticed the issue when trying to run a Ruby on Rails server locally. The response from running rails s looked something like:

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"?

Alright, so this is saying the server isn’t running or listening to requests. Checking brew services list to see the output rendered:

Brew services list output

Next was looking up what a 256 error which led me to an excellent StackOverflow post. Following the post suggested three step process of: stopping the service, removing the pid file, and restarting the service.

Brew services stop output

The pid file can be found in one of two locations:

I found mine within the /opt/ directory. Last was just restarting the service.

Brew services start output

After this running rails s worked as expected.

Thanks for reading it was a quick one.

« Previous Post
Don't Slack on Site Reliability
Next Post »
When is an Array an Array? Strategies for checking Array equality in Ruby

Join the conversation

comments powered by Disqus