MacでRailsアプリ開発中に、rails db:migrateをしたらPG::ConnectionBad: FATAL: the database system is starting upが出た
現象
ターミナル
$ bundle exec rails db:migrate
rails aborted!
PG::ConnectionBad: FATAL: the database system is starting up
/Users/jun/dic/Task-twitterclone/Rblog/vendor/bundle/ruby/2.6.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
...
解決策
$ rm /usr/local/var/postgres/postmaster.pid // postmaster.pidを削除
$ brew services restart postgresql // postgresql再起動
接続確認
$ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------------------------+-------+----------+---------+-------+-------------------
FACEBOOK_EXAM_development | jun | UTF8 | C | C |
FACEBOOK_EXAM_test | jun | UTF8 | C | C |
GraphQL-app_development | jun | UTF8 | C | C |
OK!
参考
https://qiita.com/hirocueki2/items/327dc6e87005edf622ad
https://blog.n-z.jp/blog/2020-01-08-homebrew-postgresql.html
https://qiita.com/opiyo_taku/items/2fc4bef8a6bfd468de6a