PG错误无法连接到服务器:连接被拒绝服务器是否在端口5432上运行? [英] PG Error could not connect to server: Connection refused Is the server running on port 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连接?无法连接到服务器:Connection
拒绝服务器是否在主机"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;
- PostgreSQL版本是9.3.4
- 我通过HomeBrew安装了它
- 我的database.yml文件中有
host: localhost
- Rails版本4.1.1,ruby 2.0.0p247(2013-06-27修订版41674)[x86_64-darwin12.5.0]
- 先按
brew uninstall postgresql
,然后按brew install postgresql
- 试图访问我的postgres.conf文件,但不允许通过PGAdmin和命令行访问
-
Ran
locate pg_hba.conf
并枪杀了这个东西;
- PostgreSQL version is 9.3.4
- I have it installed through HomeBrew
- I have
host: localhost
in my database.yml file - Rails version 4.1.1, ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
- Ran
brew uninstall postgresql
thenbrew install postgresql
- Tried to access my postgres.conf file but wasn't allowed through PGAdmin and command line
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: 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"?
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,则进程正在运行,但此处/usr/local/var/postgres/
中缺少postmaster.pid
文件.因此,您需要启动创建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屋!