LoginSignup
0
0

More than 1 year has passed since last update.

ターミナルでRailsを起動するとPostgreSQLが突然エラーになった。

Last updated at Posted at 2022-02-14

エラー内容

ActiveRecord::ConnectionNotEstablished (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"?

結論、私の場合、下記で解決しました。

postmaster.pidの削除。

rm /usr/local/var/postgres/postmaster.pid

原因

PostgreSQLを停止すると削除されるが、macOSが正常に終了しなかった場合、プロセスID(PID)が残ったままでエラーになる場合があるとのこと。確かにターミナルをちゃんと終了せずにMacを閉じた覚えがあります。

その他やったこと

PostgreSQLの起動、停止、リスタート
上記をすると解決した記事を見て、最初にやってみました。
ですが効果がなかったので、pidを削除しました。
削除してから起動、停止、リスタートを試すと正常に起動した経緯です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0