トップページへ

PostgreSQLで「could not connect to server」となる場合の対処

小粋空間 » PostgreSQL » PostgreSQLで「could not connect to server」となる場合の対処

PostgreSQLで「could not connect to server」となる場合の対処について紹介します。

1.問題点

psqlコマンド(PostgreSQLのターミナル型フロントエンド)を実行したところ、次のようなエラーが発生しました。

[foo@hoge html]$ psql database
psql: could not connect to server: そのようなファイルやディレクトリはありません
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

が、エラーの原因がわかりません。

2.原因と対処

psコマンドで本来出力されるプロセスはpostmasterです(下記)がこれが表示されていませんでした。

$  ps -ef|grep postmaster
postgres  7983     1  0 May16 ?        00:00:07 /usr/bin/postmaster -p 5432 -D /usr/local/pgsql/data

ということで、PostgreSQLが起動していなかったのが原因のようです。

ちなみに、postmasterは次のように起動します。

$ postmaster -D /usr/local/pgsql/data >logfile 2>&1 &

"-D"オプションはpostmasterが使用するデータディレクトリを指定します(下記は一例ですので詳細は調べてください)。

« 前の記事へ

次の記事へ »

トップページへ