昨日、Terminal上で正常にRailsを終了させずシステム終了した。
翌朝、起動した際にエラーが出た。
PG::ConnectionBad at /
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
普通にpostgresqlを再起動すると
FATAL: lock file "postmaster.pid" already exists
と言われる。
○正常終了しなかったためにpidファイルが残っているのが原因
手順
1:pidファイルの削除
2:postgresqlの再起動
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
1:pidファイルの削除
find /usr/local/var/postgres/postmaster.pid
→ファイルがあるか確認
rm /usr/local/var/postgres/postmaster.pid
→pidファイルの削除
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
2:postgresqlの再起動
brew services stop postgresql
→postgresql 終了
brew services start postgresql
→postgresql 再起動
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
直った。よかった。