7

I am running MacOS 10.14.1 (absolutely new to MacOS), I am unable to run psql command installed through brew, I get the following error, would love some help:

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

Solutions I have tried

  1. brew services start service already running
  2. brew services stop postgresql, brew services start postgresql still same error
  3. brew remove postgres, brew install postgres, psql still same error
  4. brew unlink postgresql && brew link postgresql still same error
  5. rm -f /usr/local/var/postgres/postmaster.pid my /usr/local/var/ does not contain a postgres/ folder

One more thing to note, when I brew install postgres I get a warning:

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall postgresql`

running brew postinstall postgresql gives the same warning.

Hopefully provided enough information to go by, happy to provide more.

3
  • Have you tried brew update ? That fixes a lot of issues when brew has some out of date modules. brew doctor will also solve some issues. If no luck, brew config and paste the results so we can see what version you are running and status. Commented Nov 25, 2018 at 9:42
  • Sure have tried brew update and brew doctor (would love to know what these do - feel free to drop a reference site) ... the output of my brew config is below (I notice the last line being Xcode: N/A I remember reading something about this... Commented Nov 25, 2018 at 9:56
  • HOMEBREW_VERSION: 1.8.3 ORIGIN: github.com/Homebrew/brew HEAD: 4021aa80dfbaa369ee357a955c0216f9566133ac Last commit: 8 days ago Core tap ORIGIN: github.com/Homebrew/homebrew-core Core tap HEAD: 39e578fe3c0fbde142ea94ba2a9c6184f5aef97e Core tap last commit: 12 hours ago HOMEBREW_PREFIX: /usr/local CPU: quad-core 64-bit kabylake Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby Clang: 10.0 build 1000 Git: 2.19.1 => /usr/local/bin/git Curl: 7.54.0 => /usr/bin/curl macOS: 10.14.1-x86_64 CLT: 10.1.0.0.1.1539992718 Xcode: N/A Commented Nov 25, 2018 at 9:57

3 Answers 3

2

The reason for this is that the process is running but the postmaster.pid file is missing from /usr/local/var/postgres/, so you need to start the process for Postgres which creates postmaster.pid.

If the process is already running,

Stop it manually using the command below:

pg_ctl -D /usr/local/var/postgres stop -s -m fast

Start it manually using the command below:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

now all should be working just fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Super. It's working for me on Mac. I need run this before: brew services stop postgresql
0

Try this

initdb /usr/local/var/postgres

Comments

-3

I just hit this with an existing brew install of 12.1.

brew uninstall postgresql
brew install postgresql

This fixed it. Also took me from 12.1 to 12.3.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.