首先请注意,我在 Stack Overflow 和网络上的文章中发现了几个类似的问题,但没有一个能帮助我解决我的问题:
- PG Error could not connect to server: Connection refused Is the server running on port 5432?
- PG::ConnectionBad - could not connect to server: Connection refused
- psql: could not connect to server: Connection refused
问题来了:
- 我有一个非常棒的 Rails 应用程序。
- 我和我的合作者使用 GitHub 一起工作。
- 我们有一个
master
和一个mvp
分支。 - 我最近用 Homebrew (Mac) 更新了我的
git
版本。 - 我们使用 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
文件。
知道如何解决这个问题吗?
最佳答案
运行 postgres -D/usr/local/var/postgres
你应该会看到如下内容:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 379) running in data directory "/usr/local/var/postgres"?
然后在提示中运行kill -9 PID
你应该可以开始了。
关于ruby-on-rails - 服务器是否在主机 "localhost"(::1) 上运行并在端口 5432 上接受 TCP/IP 连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37307346/