LoginSignup
7
6

More than 5 years have passed since last update.

PostgreSQLでRails serverが起動しないときのエラー解決法2

Last updated at Posted at 2016-07-15

Rails serverが起動しないときのエラー解決法

>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を起動し、任意のページが表示されました。

7
6
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
7
6