Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

5: Input/output error Error: Failure while executing; `/bin/launchctl bootstrap gui/502 and FATAL: password authentication failed for user

The error 5: Input/output Error: Failure while executing; /bin/launchctl bootstrap gui/502 /Users/Andrea/Library/LaunchAgents/homebrew.mxcl.postgresql.plist exited with 5 is occurring when typing in the command "brew services start postgresql".

I am trying to create a database using homebrew and postgresql. If I type the command "brew services stop postgresql" and then start it back up the error does not occur. But will reoccur on the initial start of postgresql.

After, I stop postgresql and restart it using homebrew I type in "createdb 'test'. This error appears:

"error: could not connect to database template1: FATAL: password authentication failed for user "Andrea". Initially I tried to primarily work on the password authentication with no luck.

Here are the steps I have taken:

  1. I have changed the method column to trust in my hba_pg files.
  2. I have tried the command ALTER in the terminal to change the password.
  3. I created a root login on my computer, where I tried to access the file and use the root's password to create the database.
  4. The command chpass to change my user's password.

Help would be much appreciated. Thank you!

like image 427
Andrea Everett Avatar asked Sep 07 '21 21:09

Andrea Everett


3 Answers

This is what I did to resolve on my Mac.

  1. Looked at the postgres.log cat /usr/local/var/log/postgres.log | tail -100
  2. Found the following error on my logs FATAL: lock file "postmaster.pid" already exists
  3. Fix above PID issue and restart the server.
rm /usr/local/var/postgres/postmaster.pid 
brew services restart postgresql
like image 53
Gajen Sunthara Avatar answered Sep 26 '22 23:09

Gajen Sunthara


Sometimes this can be solved by simply running

brew services restart postgresql

instead of

brew services start postgresql

It happens when a previous postgres process doesn't terminate properly (maybe because you killed a psql process in activity monitor or otherwise). Restarting appears to properly unlock/delete the postmaster.pid file where "start" doesn't.

like image 24
Ben Wilson Avatar answered Sep 23 '22 23:09

Ben Wilson


On the m1 mac I had the same issue and had to remove the postmaster.pid file as well. For m1 macs, the file is at /opt/homebrew/var/postgres/postmaster.pid, so I ran

/opt/homebrew/var/postgres/postmaster.pid

and I could brew services start postgresql successfully.

like image 42
Mark VanLandingham Avatar answered Sep 23 '22 23:09

Mark VanLandingham