LoginSignup
12
10

More than 3 years have passed since last update.

PostgreSQLで接続エラー「psql: could not connect to server〜"/tmp/.s.PGSQL.5432"?」への対処

Last updated at Posted at 2019-05-25

環境

macOS Mojaveバージョン10.14.4

エラー内容

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

やったこと①

postgresを再起動すれば普通にいけるんじゃないかと思い

brew services restart postgresql

をしたが状況は変わらない。

やったこと②

.pidというプロセスが残ってしまっている可能性があるので、

rm /usr/local/var/postgres/postmaster.pid

でプロセスを削除しようとしたがそのようなファイルはないと言われてしまう。

やったこと②

上記の記事を参考に

$ cd /usr/local/Cellar/postgresql
$ curl -o fixBrewLionPostgresql.sh http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh
$ chmod 777 fixBrewLionPostgresql.sh
$ ./fixBrewLionPostgresql.sh

ここまでコマンドを打つも最後のコマンド

 $ pg_ctl -D /usr/local/var/postgres start

を打った際に

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
  Referenced from: /usr/local/Cellar/postgresql/11.1_1/bin/postgres
  Reason: image not found
no data was returned by command ""/usr/local/Cellar/postgresql/11.1_1/bin/postgres" -V"
The program "postgres" is needed by pg_ctl but was not found in the
same directory as "/usr/local/Cellar/postgresql/11.1_1/bin/pg_ctl".
Check your installation.

このようなエラーが発生した。

最終的に

最終的にPostgreSQLのディレクトリを削除し、再インストール。初期化したあと起動してなんとか解決。


この記事に書いてあるコマンドを打ったあとpsqlコマンドを確認してみると

psql: FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory

このようなエラーが出たが、


pgrep -f 'postgres' | xargs sudo kill

この記事を参考に必要のないプロセスを切ることにより解決しました!

12
10
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
12
10