1

I'm getting a 'psycopq2.OperationalError' when executing: python manage.py syncdb. The postgresql server seems to be up and running when tested with a djangostack script. Anyone run across this? Just going through the django tutorial and setting things up. Complete newbie to the framework... I've found a bunch of similar problems on this forum, but none seems like an exact match... Thanks!

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 56, in handle_noargs
    cursor = connection.cursor()
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/db/backends/__init__.py", line 75, in cursor
    cursor = self._cursor()
  File "/Applications/djangostack-1.2.5-0/apps/django/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 136, in _cursor
    self.connection = Database.connect(**conn_params)
psycopg2.OperationalError: 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"?
Chris Travers
  • 25,424
  • 6
  • 65
  • 182
Igor
  • 63
  • 1
  • 1
  • 6
  • Try connecting via a network connection instead of a unix domain socket. Usually that is easier to setup. – Wolph Feb 22 '11 at 02:25
  • Hmm, that sounds over my head :) Shouldn't this function work with the default connection? There must be something else I'm not doing right... Is a django dev environment easier to setup under Windows? This has been painful under OSX so far... – Igor Feb 22 '11 at 03:03
  • 1
    Tried, this fine solution [link](http://efod.se/blog/archive/2010/02/06/pscopg2-operationalerror) but I still get the message after setting the port to the same numbers in both django's settings.py and postgresql.conf. Bitnami's djangostack, btw, hardcodes the port into their startup script djangostack-1.2.5-0/postgresql/scripts/ctl.sh which overrides anything you do in postgresql.conf. i.e. change it there instead. – Igor Feb 22 '11 at 15:34
  • Final answer: bitnami's djangostack 1.2.5 which I installed sets up 'postgres' as the user name to be used with postgresql in django project's settings.py. the stack's makers just never tell you they've done it. Other than that, bitnami's stack works great. – Igor Feb 24 '11 at 00:03

1 Answers1

0

To summarize the comments in an answer, the basic problem is that Bitami requires settings to be set in other files.

  1. The port must be set in djangostack-1.2.5-0/postgresql/scripts/ctl.sh

  2. Some other settings, including the username of postgres, get set in the settings.py so this may need to be changed as well.

Chris Travers
  • 25,424
  • 6
  • 65
  • 182