我正在尝试运行 Django 的 syncdb 操作并收到以下错误:
psycopg2.OperationalError: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
我已阅读此问题的答案并尝试了以下方法:
- 在 /Library/PostgreSQL/9.1/data/potsgresql.conf 中将“listen_address”更改为“localhost”或“*”
- 在我的 settings.py 文件中将“主机”更改为“本地主机”(对于 Django)
- 用户在 settings.py 中设置为“postgres”,密码正确
(我在每一步之后都重新启动了 postgresql 服务器。)
我还检查了我的 pg_hba.conf 文件以查看 Unix 域套接字是否正在接受来自所有用户的连接(基于此页面)。这是我在那里的:
# "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
我以前从来没有遇到过这个问题。我最近升级到了 Lion,并且正在开发一个新的 virtualenv,并且安装了最少的模块。