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

use*_*994 3 ruby postgresql macos ruby-on-rails-4

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

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

这是一份清单,以及我尝试的事项清单;

  1. PostgreSQL版本是9.3.4
  2. 我通过HomeBrew安装它
  3. 我有host: localhost我的database.yml文件
  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. Ran locate pg_hba.conf和终端出局了;

    WARNING: The locate database (/var/db/locate.database) does not exist.
    
    Run Code Online (Sandbox Code Playgroud)
  8. 我也尝试过使用rails 4.0,但我仍然遇到了问题

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

  10. 当我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"?

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

更新:

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

Nik*_*are 13

这比你想象的要容易得多,因为如果你更新你的mac,那么进程正在运行但是postmaster.pid文件从/usr/local/var/postgres/这里丢失了.所以你需要为postgres启动创建postmaster.pid的进程.

如果进展正在运行 -

手动停止:

pg_ctl -D /usr/local/var/postgres stop -s -m fast
Run Code Online (Sandbox Code Playgroud)

手动启动:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Run Code Online (Sandbox Code Playgroud)

现在一切正在......


Eve*_*nce 13

在命令行中运行

postgres -D /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)

如果结果像下一个

LOG:  skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.
Run Code Online (Sandbox Code Playgroud)

brew postgresql-upgrade-database
Run Code Online (Sandbox Code Playgroud)

基于这篇文章


Waq*_*ana 12

如果你是通过brew安装的

$ brew services stop postgresql
#adjust below  path accordingly to your machine 
$ rm /usr/local/var/postgres/postmaster.pid 
$ brew services start postgresql
Run Code Online (Sandbox Code Playgroud)