まず最初に、Stack Overflow や Web 上の記事で同様の質問をいくつか見つけたのですが、どれも私の問題を解決するのに役立たなかったことに注意してください。
- PG エラーによりサーバーに接続できませんでした: 接続が拒否されました。サーバーはポート 5432 で実行されていますか?
- PG::ConnectionBad - サーバーに接続できませんでした: 接続が拒否されました
- psql: サーバーに接続できませんでした: 接続が拒否されました
さて、問題は次の通りです。
- 完璧に動作する Rails アプリがあります。
- 共同作業者とは、GitHub を使用して共同作業を行っています。
master
と のブランチがありますmvp
。- 最近、
git
Homebrew (Mac) でバージョンを更新しました。 - アプリをローカルで起動するには、Foreman を使用します。
ここで、アプリをローカルで起動しようとすると、次のエラーが発生します。
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?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
コンピュータを何度か再起動してみました。
以下の内容も確認しました/usr/local/var/postgres
:
PG_VERSION pg_dynshmem pg_multixact pg_snapshots pg_tblspc postgresql.conf
base pg_hba.conf pg_notify pg_stat pg_twophase postmaster.opts
global pg_ident.conf pg_replslot pg_stat_tmp pg_xlog server.log
pg_clog pg_logical pg_serial pg_subtrans postgresql.auto.conf
ご覧のとおり、postmaster.pid
そこにはファイルがありません。
これを修正するにはどうすればいいでしょうか?
ベストアンサー1
実行するpostgres -D /usr/local/var/postgres
と、次のような画面が表示されます。
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 379) running in data directory "/usr/local/var/postgres"?
次にkill -9 PID
HINTを実行します
これで準備完了です。