ฉันใช้งานแอพพลิเคชั่นสำหรับการพัฒนาด้วย postgresql 9.3 เมื่อฉันพยายามเริ่มต้นเซิร์ฟเวอร์ผู้โดยสารวันนี้ฉันได้รับ:
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ไป127.0.0.1เป็นแทนlocalhostและมันได้ทำเคล็ดลับเซิร์ฟเวอร์รีสตาร์ท ฉันยังมีการแก้ไขการตั้งค่าฐานข้อมูลการใช้งานของฉันและชี้ไปที่แทน127.0.0.1 localhostแต่คำถามคือตอนนี้ทำไมถือว่า localhost จะเป็น217.74.65.145และไม่ได้127.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
example.comเป็นชื่อโดเมน
sudo netstat -anlp | grep 5432?