Home > Back-end >  Error when start the postgres service with homebrew using Mac OS
Error when start the postgres service with homebrew using Mac OS

Time:10-15

I installed postgresql 10 with the classic command:

brew install postgresql@10

Then I started the service:

brew services start postgresql@10

The output says:

Successfully started postgresql@10 (label: homebrew.mxcl.postgresql@10)

but when I run this command:

brew services

This is what I get:

Name          Status  User         Plist
cassandra     stopped              
postgresql    stopped              
postgresql@10 error   username /opt/homebrew/opt/postgresql@10/homebrew.mxcl.postgresql@10.plist  

It seems that the service in not running correctly. Previously I had another version of Posgresql. It was the version 10 again but installed with the installer offered but the postgresql's webpage. However I should have removed it.

I check with this command to see used ports:

lsof -nP  c 15 | grep LISTEN

and I don't have services using the port 5432 (the default port used by postgresql).

CodePudding user response:

I shared the procedure to investigate further and maybe solve the problem.

  1. Check the file /opt/homebrew/opt/postgresql@10/[email protected]. This path is given by the brew services command.
  2. Open the file and see where the log is written. In my case:
<key>StandardErrorPath</key>
<string>/opt/homebrew/var/log/postgresql@10.log</string>
  1. Look at the log. I my case I saw that there was a file locked, probably by the previous instance of postgresql that didn't release the lock. The restart of my Mac solved the issue.
  • Related