PG 错误无法连接到服务器:连接被拒绝 服务器是否在端口 5432 上运行? [英] PG Error could not connect to server: Connection refused Is the server running on port 5432?

查看:81
本文介绍了PG 错误无法连接到服务器:连接被拒绝 服务器是否在端口 5432 上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新了我的机器(运行 Mountain Lion 的 MacBook Pro),从那时起,每当我设置 Rails 项目时,我的机器就会崩溃并且无法连接到 PG.目前,这是我尝试访问 localhost 时遇到的错误;

I recently updated my machine (MacBook Pro running Mountain Lion) and ever since then, whenever I set up a rails project, my machine craps out and cannot connect to PG. Currently, this is the error I am getting when I try to go to localhost;

PG::ERROR 无法连接到服务器:连接被拒绝 服务器是否在主机localhost"上运行
(::1) 并接受端口 5432 上的 TCP/IP 连接?无法连接到服务器:连接
拒绝服务器是否在主机localhost"(127.0.0.1) 上运行并接受端口 5432 上的 TCP/IP 连接?无法连接到服务器:连接被拒绝服务器是否在主机localhost"(fe80::1) 上运行并接受端口 5432 上的 TCP/IP 连接?

PG::ERROR 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? could not connect to server: Connection refused Is the server running on host "localhost" (fe80::1) and accepting TCP/IP connections on port 5432?

这是一个清单,以及我尝试过的事情的清单;

Here is a checklist, and list of things I have tried;

  1. PostgreSQL 版本为 9.3.4
  2. 我是通过 HomeBrew 安装的
  3. 我的 database.yml 文件中有 host: localhost
  4. Rails 版本 4.1.1,ruby 2.0.0p247(2013-06-27 修订版 41674)[x86_64-darwin12.5.0]
  5. brew uninstall postgresql 然后 brew install postgresql
  6. 尝试访问我的 postgres.conf 文件,但不允许通过 PGAdmin 和命令行
  7. locate pg_hba.conf 和终端拍出来;

  1. PostgreSQL version is 9.3.4
  2. I have it installed through HomeBrew
  3. I have host: localhost in my database.yml file
  4. Rails version 4.1.1, ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
  5. Ran brew uninstall postgresql then brew install postgresql
  6. Tried to access my postgres.conf file but wasn't allowed through PGAdmin and command line
  7. Ran locate pg_hba.conf and terminal shot this out;

WARNING: The locate database (/var/db/locate.database) does not exist.

  • 我也尝试过使用 rails 4.0 但我仍然遇到问题

  • I have also tried using rails 4.0 but I still get the problem

    我仍然可以在我的计算机上处​​理在我更新计算机之前启动/完成的其他项目.

    I can still work on other projects on my machine that were started/finished before I updated my computer.

    当我从终端运行 psql 时,我得到psql: 无法连接到服务器: 没有那个文件或目录服务器是否在本地运行并接受Unix 域套接字/tmp/.s.PGSQL.5432"上的连接?

    When I run psql from my terminal I get psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

    我真的迷失在这里,不知道还能做什么.任何帮助将不胜感激.

    I am really lost here, and am not sure what else to do. Any help would be much appreciated.

    更新:

    感谢这个问题,只需下载 Mac 版 Postgres.app 即可解决所有问题.现在一切都很好.

    Thanks to this question, all was resolved by simply downloading Postgres.app for Mac. Everything works great now.

    推荐答案

    这比您想象的要容易,因为如果您更新您的 mac 则进程正在运行但 postmaster.pid 文件丢失了 <代码>/usr/local/var/postgres/ 在这里.所以你需要启动创建 postmaster.pid 的 postgres 进程.

    This is quite easy than your think because If you update your mac then process is running but postmaster.pid file is missing from /usr/local/var/postgres/ here. so you need to start process for postgres which create postmaster.pid.

    如果进度正在运行,则 -

    If progress is running then -

    手动停止:

    pg_ctl -D /usr/local/var/postgres stop -s -m fast
    

    手动启动:

    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
    

    现在一切都在工作......

    now all are working...

    这篇关于PG 错误无法连接到服务器:连接被拒绝 服务器是否在端口 5432 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆