# PG ConnectionBad (could not connect to server No such file or directory)

DevFeed: [PG ConnectionBad (could not connect to server No such file or directory)](<https://devfeed.tech/articles/pg-connectionbad-could-not-connect-to-server-no-such-file-or-directory-28220.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/postgres/2020/04/08/pg-connectionbad-could-not-connect-to-server-no-such-file-or-directory.html>)

Author: Fuzzygroup

Published: 2020-04-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Development](<https://devfeed.tech/topics/development.md>), [Homebrew](<https://devfeed.tech/topics/homebrew.md>), [osx](<https://devfeed.tech/topics/osx.md>), [Rails](<https://devfeed.tech/topics/rails.md>)

Tags: [crashes](<https://devfeed.tech/tags/crashes.md>), [development](<https://devfeed.tech/tags/development.md>), [errors](<https://devfeed.tech/tags/errors.md>), [osx](<https://devfeed.tech/tags/osx.md>), [personal](<https://devfeed.tech/tags/personal.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [rails](<https://devfeed.tech/tags/rails.md>)

## AI overview

A troubleshooting note for a PostgreSQL connection error on an OSX Mojave development machine. It explains that a stale postmaster.pid file can make Homebrew falsely report PostgreSQL as running, and recommends verifying that PostgreSQL is stopped before removing the file and restarting the service.

## Source excerpt

I've recently had the situation where my personal development box (OSX Mojave, Rails, Postgres) has become unstable with, at times, multiple crashes per day. I logged in this morning and found myself getting errors like this: PG::ConnectionBad (could not connect to server: No such file or directory) I did some digging and even though Postgres appeared to be running to brew, it was a false positive due to a leftover postmaster.pd file. Here was the fix: First make sure that postgres isn't running use ps i.e. **ps auwwx grep post**. Delete the file: /usr/local/var/postgres/postmaster.pid i.e. rm /usr/local/var/postgres/postmaster.pid At this point brew will, foolishly and oddly, still think Postgres is running so do do a brew restart postgres Here's a handy Stack Overflow reference. Note: Make absolutely sure that postgres is NOT running before you delete postmaster.pid or you risk serious database corruption / data loss.