1

I tried configuring my settings.py for using postgresql as follows:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'dbname',
    'USER': 'postgres',
    'PASSWORD': 'postgres',
    'HOST': '',
    'PORT': '',

    }
}

and i get the following error while syncdb: I have postgresql.

jainesh@jp:~/Dj/projv000$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 429,     in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 191, in     run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, in     execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 56, in handle_noargs
    cursor = connection.cursor()
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 250, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/usr/local/lib/python2.7/dist-    packages/django/db/backends/postgresql_psycopg2/base.py", line 140, in _cursor
    self.connection = Database.connect(**conn_params)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
    connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

jainesh@jp:~/Dj/projv000$ 

Whats the problem with it ? Thanks!

  • possible duplicate of [Can't connect the postgreSQL with psycopg2](http://stackoverflow.com/questions/5500332/cant-connect-the-postgresql-with-psycopg2) – jordiburgos Nov 30 '14 at 19:03
  • 1
    Well... is the server running locally and accepting connections on Unix domain socket `/var/run/postgresql/.s.PGSQL.5432`? – Mike DeSimone Nov 30 '14 at 19:03
  • @MikeDeSimone I am not getting what you wanna say. –  Nov 30 '14 at 19:17
  • @jordiburgos I tried that but am getting an error NameError: name 'psycopg2' is not defined –  Nov 30 '14 at 19:21

0 Answers0