PostgreSQL无法创建任何TCP/IP套接字';小牛队
我正在通过brew安装 错误消息: 当我打电话时PostgreSQL无法创建任何TCP/IP套接字';小牛队,postgresql,sockets,tcp,osx-mavericks,Postgresql,Sockets,Tcp,Osx Mavericks,我正在通过brew安装 错误消息: 当我打电话时 postgres 我收到了错误 LOG: could not bind IPv6 socket: Address already in use HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. LOG: could not bind IPv4 socket: Address already in u
postgres
我收到了错误
LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
运行
postgres -D /usr/local/var/postgres
创建相同的错误
createdb
两次提示我输入密码,然后说
createdb: could not connect to database template1: FATAL: password authentication failed for user "thomasmurphy"
我试过的
*卸载和重新安装pg gem,卸载和重新安装postgres
*更新命令行工具
*满足brew医生的所有需求
*编辑pg_hba.conf的权限
*编辑.bash_配置文件以确保它包含上述目录
我在我的工作电脑上,也在Mavericks上,Postgres运行得很好,所以我觉得这有点像边缘案例。要解决这个问题,我还可以指出哪些其他向量?您得到的错误是因为PostgreSQL正在运行。我怎么知道?因为它拒绝了你的密码。这很清楚 现在,您真正的问题可能是,在修改pg_hba.conf后需要重新启动PostgreSQL,以提供信任访问。然后你可以:
ALTER USER foo WITH PASSWORD 'bar';
关于启动和重新启动PostgreSQL,请参见以下问题:您得到的错误是因为您的主机坏了。检查您的
/etc/hosts
文件
将
127.0.0.1 localhost
放在主机的第一行。Linux:通过在命令行运行ifconfig
确保环回接口已启动。如果它没有打开,您可以使用/sbin/ifconfig lo 127.0.0.1
打开它。可能不是因为您的/etc/hosts
坏了。即使正确的行位于/etc/hosts
中,它也可能会破坏本地主机的DNS查找
检查nslookup localhost
,查看是否得到127.0.0.1
。还可以使用getenthosts localhost
进行检查。在用户Postgres运行时也要检查这些选项。在这种情况下,需要检查多个场景和位置。有一次因为这个而迷路了。
通常默认的主机
文件应如下所示:
[root@localmachine ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
要确认localhost
能够解析,请使用ping
进行测试:
[root@localmachine ~]# ping localhost
检查cat/etc/nsswitch.conf | grep hosts
并确认文件是否存在:
# hosts: files dns
# hosts: files dns # from user file
#hosts: db files nisplus nis dns
hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname
检查/etc/hosts
文件的权限,它应该是644
(对所有进程/用户都可读):
对于那些有足够时间的人,我在这里创建了一篇详细的博文:
我提到了我是如何检查并得出结论的。您以前安装过其他版本的Postgres吗?就我而言,我试图执行:
sudo systemctl重启postgresql
那是不正确的最后我发现正确的答案是:
sudo systemctl重启postgresql-12
我有两个版本的Postgres…一台机器重新启动为我解决了这个错误。另一个邮局主管已经在5432端口上运行了吗?
-是吗?@RichardHuxton Fair question。但没有,5432上没有连接。我在浏览器中输入localhost:5432并收到“未收到数据”,这听起来确实像是服务器正在运行,但没有发送响应。这对你的理解准确吗?是否有一个bashshell命令我应该是问题,是不是没有那么笨拙?已经有几年没有mac了。您是否安装了lsof()或netcat()?尝试lsof-i-n-P | grep5432
或nclocalhost 5432
。如果失败了,听起来不错。我在那个盒子上还有一个Ubuntu虚拟机,所以我也会在那里试一试,以缩小出错的可能性。我开始怀疑问题是它没有认证我是超级用户来访问根帐户。我不能再重现这个问题了,因为我在这台机器上安装了PostgreSQL。这个答案似乎与我遇到的问题一致,所以我会接受。它在我的情况下起了作用,但我无法解释为什么?您还可以告诉我在hosts文件中没有该条目有什么问题吗?localhost与127.0.0.1不同。在某些应用程序中,本地主机不需要转换为IP地址。但是,我知道它需要在这里进行翻译。PostgreSQL和hosts配置文件都没有为我设置localhost和IP.spot on之间的关联!工作得很有魅力。谢谢我的人!非常感谢。我从未想到过这一点。/etc/nsswitch.conf
中的hosts
行可能也与此相关。
[root@localmachine ~]# ls -al /etc/hosts
-rw-r--r--. 1 root root 240 Aug 14 08:04 /etc/hosts