[英]Postgres cannot connect to server on Unix domain socket 5432
Using Postgres 9.2.2, I keep getting this error when I try to start up rails server or run psql
使用Postgres 9.2.2,当我尝试启动rails服务器或运行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"?
This command, when run: 此命令在运行时:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
says server starting, but when I go to check processes, no postgres process is running 说服务器启动,但是当我去检查进程时,没有运行postgres进程
My paths are correct 我的道路是正确的
$ which psql
/usr/local/bin/psql
$ which pg_ctl
/usr/local/bin/pg_ctl
If I run this command: 如果我运行此命令:
initdb /usr/local/var/postgres -E utf8
It will connect to the socket.... but it also requires me to remove my databases, which is pretty frustrating. 它将连接到套接字....但它也需要我删除我的数据库,这是非常令人沮丧的。 This seems happens every time I restart. 这似乎每次重新启动时都会发生。
Using 运用
I found similar threads on stack overflow but none of the solutions seemed to work. 我在堆栈溢出时发现了类似的线程,但没有一个解决方案似乎有效。
Screw it. 算了。 I just installed Postgres.app by Heroku. 我刚刚安装了Heroku的Postgres.app。 No more messy issues. 没有更混乱的问题。
I saw this issue arise again once more with someone who actually had Postgres.app installed. 我看到这个问题再一次出现在实际安装了Postgres.app的人身上。 Though, it's unclear why his threw this error because I've never seen it before with Postgres.app. 虽然,目前还不清楚他为什么抛出这个错误,因为我之前从未见过Postgres.app。
The solution was changing the database.yml
file from: 解决方案是从以下位置更改database.yml
文件:
development: &default
adapter: postgresql
database: myapp_development
encoding: utf8
min_messages: warning
pool: 5
timeout: 5000
test:
<<: *default
database: myapp_test
To: 至:
development: &default
adapter: postgresql
database: myapp_development
encoding: utf8
min_messages: warning
pool: 5
timeout: 5000
host: localhost
test:
<<: *default
database: myapp_test
Only difference is the "host" line 唯一的区别是“主机”线
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.