python - django.db.utils.OperationalError Could not connect to server -


i not sure how fix issue

i have no idea why getting error when try runserver:

performing system checks...  system check identified no issues (0 silenced). unhandled exception in thread started <function wrapper @ 0x1085589b0> traceback (most recent call last):   file "/library/python/2.7/site-packages/django/utils/autoreload.py", line 222, in wrapper     fn(*args, **kwargs)   file "/library/python/2.7/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run     self.check_migrations()   file "/library/python/2.7/site-packages/django/core/management/commands/runserver.py", line 159, in check_migrations     executor = migrationexecutor(connections[default_db_alias])   file "/library/python/2.7/site-packages/django/db/migrations/executor.py", line 17, in __init__     self.loader = migrationloader(self.connection)   file "/library/python/2.7/site-packages/django/db/migrations/loader.py", line 49, in __init__     self.build_graph()   file "/library/python/2.7/site-packages/django/db/migrations/loader.py", line 184, in build_graph     self.applied_migrations = recorder.applied_migrations()   file "/library/python/2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations     self.ensure_schema()   file "/library/python/2.7/site-packages/django/db/migrations/recorder.py", line 49, in ensure_schema     if self.migration._meta.db_table in self.connection.introspection.get_table_list(self.connection.cursor()):   file "/library/python/2.7/site-packages/django/db/backends/__init__.py", line 165, in cursor     cursor = self.make_debug_cursor(self._cursor())   file "/library/python/2.7/site-packages/django/db/backends/__init__.py", line 138, in _cursor     self.ensure_connection()   file "/library/python/2.7/site-packages/django/db/backends/__init__.py", line 133, in ensure_connection     self.connect()   file "/library/python/2.7/site-packages/django/db/utils.py", line 94, in __exit__     six.reraise(dj_exc_type, dj_exc_value, traceback)   file "/library/python/2.7/site-packages/django/db/backends/__init__.py", line 133, in ensure_connection     self.connect()   file "/library/python/2.7/site-packages/django/db/backends/__init__.py", line 122, in connect     self.connection = self.get_new_connection(conn_params)   file "/library/python/2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 134, in get_new_connection     return database.connect(**conn_params)   file "/library/python/2.7/site-packages/psycopg2/__init__.py", line 164, in connect     conn = _connect(dsn, connection_factory=connection_factory, async=async) django.db.utils.operationalerror: not connect server: connection refused         server running on host "127.0.0.1" , accepting         tcp/ip connections on port 5432? 

when try connect postgres:

psql: not connect server: no such file or directory         server running locally , accepting         connections on unix domain socket "/tmp/.s.pgsql.5432"? 

settings.py:

databases = {     'default': {         'engine': 'django.db.backends.postgresql_psycopg2',         'name': 'beerad',         'user': 'bli1',         'password': '',         'host': '127.0.0.1',         'port': '5432',     } } 

it can issues:

  1. postgresql not running. check sudo service postgresql status
  2. your postgressql not running on port 5432. can check typing sudo netstat -nl | grep postgres

  3. you have wrong trying connect db username, password or databasename. check postgres ask connect , db_name want access to.

  4. problems postmaster.pid in postgres. can happen because of shutdown unproperly done. makes remind pid alive doesn't allow server start. fix have to:

     * rm /usr/local/var/postgres/postmaster.pid   * pg_resetxlog -f /usr/local/var/postgres 

    after should run if make runserver of postgres

help in mac osx: how start postgresql server on mac os x?


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -