可能的重复:
PostgreSQL权限被拒绝Unix域套接字上的错误"/var/pgsql_socket/.s.pgsql.5432"-Lion Server 10.7.3或Lion Server 107.4
我使用postgres作为Rails的后端数据库,但由于配置错误,它已经停止工作,但我看不清它是什么。
我的postgres版本是9.1.4,安装在/usr/bin中
我运行的是ruby 1.9.3版本,但我必须在rvm中手动切换到它,因为默认的1.8.7版本会出现。
我正在运行Rails 3.2.8
我的配置文件pg_hba.conf看起来像:
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
postgres.conf文件中的大多数行都被注释掉了,除了一些无害的行,比如:
log_destination = 'stderr'
listen_addresses = '*'
port = 5432
max_connections = 100
我还安装了适用于Mac的"Postgres应用程序"(请参阅postgresapp.com/documentation),据说它正在5432端口上运行和侦听。
当我运行ps-ax|grep post时,我看到:
1088 ?? 0:00.08 com.heroku.postgres-service
1135 ?? 0:00.29 /Applications/Postgres.app/Contents/MacOS/bin/postgres -D /Users/rickc/Library/Application Support/Postgres/var -p5432
1137 ?? 0:01.14 postgres: writer process
1138 ?? 0:00.78 postgres: wal writer process
1139 ?? 0:00.20 postgres: autovacuum launcher process
1140 ?? 0:00.26 postgres: stats collector process
但是,当我尝试在localhost:3000上启动rails连接时,我会收到以下错误消息:PG::错误
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
我试着在这里查看了以前的帖子,当然,postgres文档也看不出这里有什么错误配置;非常感谢任何帮助。。。
这是一个postgres问题,而不是rails/ruby问题。
为了向自己证明这一点,打开一个终端并进行
psql -U username -W db_name
其中username
是您的用户名,db_name
是数据库的名称。
您应该得到"无法连接到服务器"的错误。
以下是您的操作:
tail
您在终端窗口中的postgres日志- 重新启动postgres并观看终端
您将在日志中看到该问题。如果您无法解决问题,请发布日志的相关部分,我们将进行查看。