これまで遭遇したエラーについて簡単にまとめていく。
今回は、
RailsとPostgresSQLでアプリを作成した際のエラー
エラー文(一部抜粋)
1 2 3 4 5 6 7 8 |
could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? Couldn't create 'article_base_development' database. Please check your configuration. rails aborted! PG::ConnectionBad: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? |
PostgresSQLのログを確認
1 |
$ cd /usr/local/var/log |
1 |
$ cat postgres.log |
原因のログ
1 2 |
2021-01-26 12:03:26.380 JST [11699] FATAL: database files are incompatible with server 2021-01-26 12:03:26.380 JST [11699] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.0. |
今回の原因
PostgresSQLのデータディレクトリのバージョンバージョンが異なっていること
解決法
PostgresSQLのアップデート
1 |
$ brew postgresql-upgrade-database |
以上で終了