PG Error could not connect to server: Connection refused Is the server running on port 5432?
我最近更新了我的机器(运行Mountain Lion的MacBook Pro),从那时起,每当我设置一个rails项目时,我的机器就会崩溃,无法连接到PG。目前,这是我尝试去localhost时遇到的错误;
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?
这是一份清单,以及我尝试的事项清单;
Ran
1 | WARNING: The locate database (/var/db/locate.database) does not exist. |
我也尝试过使用rails 4.0,但我仍然遇到了问题
在我更新计算机之前,我仍然可以在我的机器上处理启动/完成的其他项目。
当我从终端运行
Is the server running locally and accepting
connections on Unix domain socket"/tmp/.s.PGSQL.5432"?
我真的迷失在这里,不知道还能做什么。任何帮助将非常感激。
更新:
感谢这个问题,只需下载Postgres.app for Mac即可解决所有问题。现在一切都很好。
这比您想象的要容易得多,因为如果您更新了Mac,那么进程正在运行,但
如果进展正在运行 -
手动停止:
1 | pg_ctl -D /usr/local/var/postgres stop -s -m fast |
手动启动:
1 | pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start |
现在一切正在......
在命令行中运行
1 | postgres -D /usr/local/var/postgres |
如果结果像下一个
1 2 3 | 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. |
跑
1 | brew postgresql-upgrade-database |
基于这篇文章