Rails server is crashing

Posted by Ife Odugbesan

almost 2 years ago

0

postgres rails

Error message:

PG::ConnectionBad: 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"


A pid file could be blocking postgres from starting up. Try removing this file and then restarting postgres

rm /usr/local/var/postgres/postmaster.pid
brew services restart postgresql
For Apple M1 (Big Sur) users, do this instead:

rm /opt/homebrew/var/postgres/postmaster.pid
brew services restart postgresql

The alumni community has posted 3 alternative solutions

Posted by Ben McLaren

8 months ago

Check Homebrew Installation Path

Run the following command to confirm where Homebrew is installed:

brew --prefix

This will display the base directory where Homebrew is installed (e.g., /usr/local or /opt/homebrew).

Recreate the PostgreSQL Data Directory

After confirming Homebrew's location, ensure the PostgreSQL data directory exists. Replace /opt/homebrew with your Homebrew prefix if it differs.

mkdir -p $(brew --prefix)/var/postgres
initdb $(brew --prefix)/var/postgres
Start PostgreSQL

Restart PostgreSQL through Homebrew:

brew services start postgresql@14


0


Posted by Ife Odugbesan

over 1 year ago

If it has the following 

fe_sendauth: no password supplied
The following link has a working solution

https://www.levoyage.dev/issues/postgresql-no-password-supplied

0


Posted by Ife Odugbesan

almost 2 years ago

Firstly try to upgrade postgres using:

brew upgrade postgres
If not then try:

brew services stop postgresql
brew postgresql-upgrade-database
brew services start postgresql
If this didn't fix it another solution is to remove postgres and reinstall it. Bear in mind that this will erase any data you had in your databases.

  1. brew uninstall postgres
  2. rm -rf /usr/local/var/postgres
  3. brew install postgres
  4. brew services start postgresql

0