HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlCritical

PostgreSQL not running on Mac

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlrunningmacnot

Problem

The error in its entirety reads:


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

This is my second time setting up Postgresql via Homebrew on my Mac, and I have no clue what is going on. Previously, it had been working. At some point, I must've entered a command that messed things up. I'm not sure. Now, whenever I enter a SQL command from the command line, I receive the above message. I've run a command to check whether the server is running, and it apparently is not. If I attempt to start the server using


$ postgres -D /usr/local/pgsql/data

I receive the following error:


postgres cannot access the server configuration file
"/usr/local/pgsql/data/postgresql.conf": No such file or directory

I've uninstalled and reinstalled Postgresql via Homebrew, but the problem persists. I'm completely at a loss as to how to get this working. Any help would be appreciated.

Solution

The problem can also be attributed to a crashed process that left postmaster.pid file behind.

$ brew services stop postgresql
# adjust path accordingly to your install, e.g. `/opt/homebrew/var/postgres/postmaster.pid`
$ rm /usr/local/var/postgres/postmaster.pid 
$ brew services start postgresql


2023 Update:
I highly recommend running PostgreSQL in a docker container and keeping your local host clean.

Code Snippets

$ brew services stop postgresql
# adjust path accordingly to your install, e.g. `/opt/homebrew/var/postgres/postmaster.pid`
$ rm /usr/local/var/postgres/postmaster.pid 
$ brew services start postgresql

Context

StackExchange Database Administrators Q#75214, answer score: 167

Revisions (0)

No revisions yet.