Sto eseguendo un'app Rails in sviluppo con Postgresql 9.3. Quando ho provato ad avviare il server passeggeri oggi, ho ottenuto:
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?
Non ho pensato molto, è successo prima. Il riavvio di postgres ha sempre risolto il problema. Quindi ho corso sudo service postgresql restarte ottenuto:
* 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!
I miei postgresql.confpunti di default: localhoste port 5432. Ho provato a cambiare la porta ma il messaggio di errore è lo stesso (tranne la modifica della porta).
Entrambi ps aux | grep postgresqle ps aux | grep postmasternon restituiscono nulla.
MODIFICARE:
Nel postgresql.confho cambiato listen_addressesal 127.0.0.1posto di localhoste lo ha fatto il trucco, il server riavviato. Ho anche dovuto modificare la configurazione db delle mie applicazioni e scegliere 127.0.0.1invece di localhost. Tuttavia, la domanda è ora, perché localhost è considerato 217.74.65.145e non 127.0.0.1?
Questo è il mio /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.comcome nome di dominio.
sudo netstat -anlp | grep 5432?