Postgresql + django (Is the server running on host "ip" and accepting TCP/IP connections on port 5432?

Put on the PostgreSQL server.
Created a user for the connection.
Asked for a password.
Created database and pointed out that the owner of the created user.
In settings py changed:
'default': {
 'ENGINE': 'django.db.backends.postgresql_psycopg2',
 'NAME': 'django_db1',
 'USER': 'user',
 'PASSWORD': 'pass66',
 'HOST': 'server Ip',
 'PORT': '5432',

Config postgresql
listen_addresses = 'ip of server'

error when trying
python migrate
@debian:/var/www/myblog_project/mysite$ python migrate
Traceback (most recent call last):
 File "", line 22, in <module>
 File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 363, in execute_from_command_line
 File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 355, in execute
 File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 283, in run_from_argv
 self.execute(*args, **cmd_options)
 File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 330, in execute
 output = self.handle(*args, **options)
 File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/", line 83, in handle
 executor = MigrationExecutor(connection, self.migration_progress_callback)
 File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/", line 20, in __init__
 self.loader = MigrationLoader(self.connection)
 File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/", line 52, in __init__
 File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/", line 209, in build_graph
 self.applied_migrations = recorder.applied_migrations()
 File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/", line 65, in applied_migrations
 File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/", line 52, in ensure_schema
 if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
 File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/", line 254, in cursor
 return self._cursor()
 File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/", line 229, in _cursor
 File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/", line 213, in ensure_connection
 File "/usr/local/lib/python2.7/dist-packages/django/db/", line 94, in __exit__
 six.reraise(dj_exc_type, dj_exc_value, traceback)
 File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/", line 213, in ensure_connection
 File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/", line 189, in connect
 self.connection = self.get_new_connection(conn_params)
 File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql/", line 176, in get_new_connection
 connection = Database.connect(**conn_params)
 File "/usr/local/lib/python2.7/dist-packages/psycopg2/", line 130, in connect
 conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Connection refused
 Is the server running on host "my ip" and accepting
 TCP/IP connections on port 5432?</module>

Checked Postgres works.
What's wrong?
The issue has been resolved, in you need to specify the HOST to
June 26th 19 at 14:19
2 answers
June 26th 19 at 14:21
If the database locally, there is no need to bother with ip, but to register anywhere localhost, type
'HOST': 'localhost',
It's on the server - Christiana_Gutmann commented on June 26th 19 at 14:24
June 26th 19 at 14:23
99% of pg_hba.conf
the remaining 1% - the firewall

Find more questions by tags PostgreSQLDjango