Saya menjalankan aplikasi rel dalam pengembangan dengan postgresql 9.3. Ketika saya mencoba memulai server penumpang hari ini, saya mendapat:
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?
Bukan masalah besar yang saya pikir, itu terjadi sebelumnya. Restart postgres selalu memecahkan masalah. Jadi saya berlari sudo service postgresql restartdan mendapatkan:
* 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.confPoin saya ke default: localhostdan port 5432. Saya mencoba mengubah port tetapi pesan kesalahannya sama (kecuali port berubah).
Keduanya ps aux | grep postgresqldan ps aux | grep postmastertidak mengembalikan apa pun.
EDIT:
Dalam postgresql.confsaya berubah listen_addressesmenjadi 127.0.0.1bukan localhostdan itu triknya, server restart. Saya juga harus mengedit konfigurasi db aplikasi saya dan arahkan ke 127.0.0.1bukan localhost. Namun, pertanyaannya sekarang, mengapa localhost dianggap 217.74.65.145dan tidak 127.0.0.1?
Itu milik saya /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
example.comsebagai nama domain.
sudo netstat -anlp | grep 5432?