私はpostgresql 9.3で開発中のrailsアプリを実行しています。今日、旅客サーバーを起動しようとしたとき、私は得ました:
PG::ConnectionBad - could not connect to server: Connection refused
Is the server running on host "localhost" (217.74.65.145) and accepting
TCP/IP connections on port 5432?
大したことはないと思っていた、それは前に起こった。postgresを再起動すると、常に問題が解決しました。だから私は走っsudo service postgresql restartて得た:
* Restarting PostgreSQL 9.3 database server
* The PostgreSQL server failed to start. Please check the log output:
2014-06-11 10:32:41 CEST LOG: could not bind IPv4 socket: Cannot assign requested address
2014-06-11 10:32:41 CEST HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2014-06-11 10:32:41 CEST WARNING: could not create listen socket for "localhost"
2014-06-11 10:32:41 CEST FATAL: could not create any TCP/IP sockets
...fail!
私postgresql.confはデフォルトを指しています:localhostとポート5432。ポートを変更しようとしましたが、エラーメッセージは同じです(ポートの変更を除く)。
どちらps aux | grep postgresqlとps aux | grep postmaster戻り何も。
編集:
で代わりpostgresql.confに変更listen_addressesし、トリックを行い、サーバーを再起動しました。また、アプリケーションのdb configを編集し、の代わりにをポイントする必要がありました。しかし、問題は今、なぜlocalhostがそうであると考えられているのかではないのですか?127.0.0.1localhost127.0.0.1localhost217.74.65.145127.0.0.1
それは私の/etc/hostsです:
127.0.0.1 local
127.0.1.1 jacek-X501A1
127.0.0.1 something.name.non.example.com
127.0.0.1 company.something.name.non.example.com
データを難読化する場合は、責任を持って行い
—
ジェニーD 14年
example.com、ドメイン名として使用してください。
sudo netstat -anlp | grep 5432?