当前位置: 首页 > 知识库问答 >
问题:

服务器是否在主机“本地主机”(::1)上运行并接受端口 5432 上的 TCP/IP 连接?

禹昆
2023-03-14

在此之前,请注意,我在Stack Overflow和网络上的文章中发现了几个类似的问题,但这些都没有帮助我解决问题:

  • PG 错误无法连接到服务器:连接被拒绝 服务器是否在端口 5432 上运行?
  • PG::连接错误 - 无法连接到服务器:连接被拒绝
  • psql:无法连接到服务器:连接被拒绝

现在,问题是:

    < li >我有一个非常好用的Rails应用程序。 < li >与我的合作者一起,我们使用GitHub进行合作。 < li >我们有< code >主和< code>mvp分支机构。 < li >我最近用家酿(Mac)更新了我的< code>git版本。 < li >我们使用Foreman在本地启动我们的应用。

现在,当我尝试在本地启动应用程序时,我收到以下错误:

PG::ConnectionBad at /
could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

我试着重启了几次我的电脑。

我还检查了/usr/local/var/postgres的内容:

PG_VERSION      pg_dynshmem     pg_multixact    pg_snapshots    pg_tblspc       postgresql.conf
base            pg_hba.conf     pg_notify       pg_stat         pg_twophase     postmaster.opts
global          pg_ident.conf   pg_replslot     pg_stat_tmp     pg_xlog         server.log
pg_clog         pg_logical      pg_serial       pg_subtrans     postgresql.auto.conf

如您所见,那里没有postmaster.pid文件。

知道我该怎么解决这个问题吗?

共有3个答案

东门涵育
2023-03-14

很可能是因为你的系统意外关机

尝试

postgres -D /usr/local/var/postgres

你可能会看到

FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 449) running in data directory "/usr/local/var/postgres"?

那就试试

kill -9 PID

实例

kill -9 419

它应该正常启动postgres

郎刚捷
2023-03-14

您很可能耗尽了电池,并且您的postgresql server没有正确关闭。

最简单的解决方法是下载官方的postgresql应用程序并启动它:它将强制服务器启动(http://postgresapp.com/)

空夕
2023-03-14

运行<code>postgres-D/usr/local/var/postgress

 FATAL:  lock file "postmaster.pid" already exists
 HINT:   Is another postmaster (PID 379) running in data directory "/usr/local/var/postgres"?

然后在提示中运行< code>kill -9 PID

你应该准备好了。

 类似资料: