PostgreSQL 无法创建任何 TCP/IP 套接字的小牛

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20198235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:30:11  来源:igfitidea点击:

PostgreSQL could not create any TCP/IP sockets' Mavericks

postgresqlsocketstcposx-mavericks

提问by Thomas Murphy

I'm installing through brew.

我正在通过 brew 安装。

The error message(s):

错误信息:

When I call

当我打电话

postgres

I receive the error

我收到错误

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

Running

跑步

postgres -D /usr/local/var/postgres

Creates the same error

创建相同的错误

createdb

prompts me for my password twice, then says,

两次提示我输入密码,然后说,

createdb: could not connect to database template1: FATAL:  password authentication failed for user "thomasmurphy"

What I've tried * Uninstalling and reinstalling the pg gem, uninstalling and reinstalling postgres * Updating command line tools * Satisying all of brew doctor's needs * editing pg_hba.conf's permissions * editing .bash_profile to be sure it includes the above directories

我试过的 * 卸载并重新安装 pg gem,卸载并重新安装 postgres * 更新命令行工具 * 满足 brew doctor 的所有需求 * 编辑 pg_hba.conf 的权限 * 编辑 .bash_profile 以确保它包含上述目录

I have Postgres running perfectly on my work computer, also on Mavericks, so this strikes me as somewhat of an edge case. What other vectors can I poke at to try to solve this?

我的 Postgres 在我的工作计算机上完美运行,也在小牛队上运行,所以这让我觉得有点边缘情况。我可以尝试哪些其他向量来尝试解决这个问题?

采纳答案by Chris Travers

The errors you are getting are because PostgreSQL is running. How do I know? Because it is rejecting your password. That's pretty clear.

您收到的错误是因为 PostgreSQL 正在运行。我怎么知道?因为它拒绝您的密码。这很清楚。

Now your real problem is probably that you need to restart PostgreSQL after modifying the pg_hba.conf to give you trust access. Then you can:

现在您真正的问题可能是您需要在修改 pg_hba.conf 以授予您信任访问权限后重新启动 PostgreSQL。然后你可以:

 ALTER USER foo WITH PASSWORD 'bar';

In terms of starting and restarting PostgreSQL, please see this question: How to start PostgreSQL server on Mac OS X?

关于PostgreSQL的启动和重启,请看这个问题: 如何在Mac OS X上启动PostgreSQL服务器?

回答by gpxlcj

The error you got is because your host is broken. Check your /etc/hostsfile.

你得到的错误是因为你的主机坏了。检查您的/etc/hosts文件。

Put 127.0.0.1 localhostat the first line of hosts.

放在127.0.0.1 localhost主机的第一行。

回答by kazou

Linux: Make sure that your loopback interface is up by running the ifconfig at the command line. If it's not up, you can use /sbin/ifconfig lo 127.0.0.1 to bring it up.

Linux:通过ifconfig 在命令行运行 确保您的环回接口已启动。如果它不起来,您可以使用/sbin/ifconfig lo 127.0.0.1 来提出它。

回答by Wildcard

It may not be that your /etc/hostsis broken. It could be something else breaking DNS lookup of localhost, even if the correct line is in /etc/hosts.

可能不是你/etc/hosts的坏了。这可能是别的东西打破DNS查找localhost即使正确的路线是/etc/hosts

Check nslookup localhostand see if you get 127.0.0.1as a result. Also check with getent hosts localhost. Check these also as the user Postgres runs as.

检查nslookup localhost并查看您是否得到127.0.0.1了结果。也检查getent hosts localhost当用户 Postgres 运行时也检查这些

回答by Anto

There are multiple scenarios and places to check in this case. Got lost once because of this. A usual default hostsfile should look like one below:

在这种情况下,有多个场景和地方需要检查。为此迷路过一次。通常的默认hosts文件应如下所示:

[root@localmachine ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

To confirm localhostis able to resolve, test using ping:

要确认localhost能够解决,请使用ping以下方法进行测试:

[root@localmachine ~]# ping localhost

Check cat /etc/nsswitch.conf|grep hostsand confirm filesis there:

检查cat /etc/nsswitch.conf|grep hosts并确认files是否存在:

#     hosts: files dns
#     hosts: files dns  # from user file
#hosts:     db files nisplus nis dns
hosts:     files mdns4_minimal [NOTFOUND=return] dns myhostname

Check permissions of /etc/hostsfile, it should be 644( readable for all processes/users` ):

检查/etc/hosts文件的权限,它应该是644(对所有进程/用户可读):

[root@localmachine ~]# ls -al /etc/hosts
-rw-r--r--. 1 root root 240 Aug 14 08:04 /etc/hosts

For those who have enough time, I've created a detailed blog post here: https://coffeewithbytes.com/blog/postgres-hostsfile-permissions/

对于那些有足够时间的人,我在这里创建了一篇详细的博客文章:https: //coffeewithbytes.com/blog/postgres-hostsfile-permissions/

I've mentioned how I checked and came to a conclusion.

我已经提到我是如何检查并得出结论的。