重新启动我的Mac,我得到了可怕的Postgres错误:

psql: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

发生这种情况的原因是由于一个无关的问题,我的macbook完全死机了,我不得不使用电源按钮进行硬重启。重启后,由于这个错误,我无法启动Postgres。


当前回答

进入/var/log/目录 运行cat postgres.log 在这里你会发现postgres失败的原因。 如果它是一个智能关闭,那么可能你的icu4c版本(Unicode的c++库)是不正确的,它与postgres链接。所以执行以下命令。

酿造升级 啤酒清理 这应该可以工作;)

其他回答

我刚刚得到了相同的问题,因为我已经把我的机器(ubuntu)更新,并得到以下错误:

无法连接到服务器:没有这样的文件或目录是服务器吗 在Unix域套接字上本地运行并接受连接 “/ var /运行/ postgresql / .s.PGSQL.5432”?

完成更新过程后,当我重新启动系统时,我的错误消失了。它的工作就像以前一样迷人。我猜这是在pg更新和另一个进程启动时发生的。

我在这里遇到了类似的问题,我解决了这个问题,如下所示。

实际上postgres进程已经死亡,要查看postgres的状态,请运行以下命令

sudo /etc/init.d/postgres status

它会说进程已死,只要启动进程

sudo /etc/init.d/postgres start

这是我的方法:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm /usr/local/var/postgres/postmaster.pid
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

对我来说,解决办法就是重启电脑。我首先尝试使用Brew服务重新启动,当它不起作用时,重新启动似乎是下一个最好的选择,然后再考虑一些更复杂的解决方案。之后一切都照常进行。

导致此错误的原因有很多,因此首先定位您的日志文件并检查其线索。它可能在/usr/local/var/log/ postgress .log或/usr/local/var/ postgress /server.log或其他地方。如果你安装了Homebrew,你可以在~/Library/LaunchAgents/ Homebrew .mx .postgresql.plist找到这个位置。