0

I'm trying to run Django's syncdb operation and am getting the following error:

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"?

I've read the answers to this question and have tried the following:

  • changing "listen_address" to "localhost" or "*" in /Library/PostgreSQL/9.1/data/potsgresql.conf
  • changing "host" to "localhost" in my settings.py file (for Django)
  • user is set to "postgres" with correct password in settings.py

(I restarted the postgresql server after each step.)

I've also checked my pg_hba.conf file to see if the Unix domain socket was accepting connections from all users (based on this page). Here's what I have there:

# "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

I never had this problem before. I somewhat recently upgraded to Lion and am working on a new virtualenv with the bare minimum of modules installed.

Community
  • 1
  • 1
tchaymore
  • 3,728
  • 13
  • 55
  • 86

2 Answers2

1

Found the answer courtesy of Bradley Ayers:

  • set "unix_socket_directory" to "/var/pgsql_socket/" in postgres.conf
  • executed following commands:
    • "$ sudo dscl . append /Groups/_postgres GroupMembership postgres"
    • "$ sudo chmod g+w,o+rx /var/pgsql_socket/"
  • restarted postgresql
tchaymore
  • 3,728
  • 13
  • 55
  • 86
0

your database is not running try

pg_ctl -D /usr/local/var/postgres  start

assuming thats where your postgre data directory is

mossplix
  • 3,783
  • 2
  • 26
  • 31