微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql – Postgres – 无法创建任何TCP / IP套接字

我正在使用 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服务postgresql重启并得到:

* 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,它完成了技巧,服务器重新启动.我还必须编辑我的应用程序的db config并指向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
你的/ etc / hosts坏了.第一行应该是读
127.0.0.1   localhost something.name.non.example.com company.something.name.non.example.com

原文地址:https://www.jb51.cc/postgresql/192522.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐