>rails s
...
could not connect to server: Connection refused (PG::ConnectionBad)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
...
MacOSのアップデート後、rails s
をしたら上記のエラーが出現
上記のリンク内を参考にpostmaster.pid
を探しに行くも、そんなものはないと言われる
コマンドライン
find /usr/local/var/postgres/postmaster.pid
No such file or directory
単にposgresが起動されていない場合があるので、ユーザー名を指定して起動
コマンドライン
sudo -u ユーザー名 postgres -D /usr/local/var/postgres
また、バックグラウンドで起動する場合
~/.zshrc
export PGDATA=/usr/local/var/postgres
起動
コマンドライン
$ pg_ctl -l /usr/local/var/postgres/server.log start
終了
コマンドライン
$ pg_ctl stop
rails sを起動し、任意のページが表示されました。