Ich verwende eine Rails-App in der Entwicklung mit postgresql 9.3. Als ich heute versuchte, den Passagierserver zu starten, bekam ich:
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?
Keine große Sache, dachte ich, das ist schon mal passiert. Ein Neustart von postgres hat das Problem immer gelöst. Also rannte ich sudo service postgresql restartund bekam:
* 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!
Meine postgresql.confPunkte zu den Vorgaben: localhostund Port 5432. Ich habe versucht, den Port zu ändern, aber die Fehlermeldung ist dieselbe (mit Ausnahme der Portänderung).
Beides ps aux | grep postgresqlund ps aux | grep postmasternichts zurück.
BEARBEITEN:
In postgresql.confich geändert , listen_addressesum 127.0.0.1statt localhostund es hat den Trick, Server neu gestartet. Ich musste auch die db-Konfiguration meiner Anwendungen bearbeiten und 127.0.0.1stattdessen auf zeigen localhost. Die Frage ist nun jedoch, warum localhost als solche angesehen wird 217.74.65.145und nicht 127.0.0.1.
Das ist mein /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.comals Domainnamen.
sudo netstat -anlp | grep 5432?