ruby-on-rails - 服务器是否在主机 "localhost"(::1) 上运行并在端口 5432 上接受 TCP/IP 连接?

标签 ruby-on-rails ruby postgresql ruby-on-rails-3 ruby-on-rails-4

首先请注意,我在 Stack Overflow 和网络上的文章中发现了几个类似的问题,但没有一个能帮助我解决我的问题:

问题来了:

  • 我有一个非常棒的 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/

相关文章:

ruby-on-rails - 使用 Passenger 和 Apache 调试 Rails

ruby-on-rails - 使 Rails 生成单引号字符串而不是双引号字符串以满足 RuboCop

ruby-on-rails - 如果有条件,从 ruby​​ 数组中获取值

ruby-on-rails - Rails respond_with 没有输出剩余调用的状态

arrays - 如何在 Ruby 中有效地连接多个数组?

ruby-on-rails - 快速将多个项目(1000/秒)添加到 sidekiq 队列?

ruby-on-rails - rvm installation -/usr/local/rvm : permission denied (Before this, 我在 Ubuntu 中误删除了主目录)

node.js - Getter 方法不适用于 PostgreSQL 模型

linux - 无法在终端代码中为带连字符 (-) 的用户名添加密码

postgresql - 表未在指定模式中创建