I have a Django project and I use a postgresql database in local and it goes perfectly with the module psycopg2, now, I put an external database and when I do a migrate it gives the following error.
django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host "local-IP", user "postgres", database "chewbacca_db", SSL on
FATAL: no pg_hba.conf entry for host "local-IP", user "postgres", database "my_db", SSL off
and in my project django I have it like that ... as always
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'my_db',
'USER': 'postgres',
'PASSWORD': 'password',
'HOST': 'external-server-IP',
'PORT': '5432'
}
}
I do not understand why I get the IP address of the local server in the error ... if in settings.py there is no such IP anywhere.
SOLUTION:
The postgresql.conf file has been modified by changing listenaddresses='localhost'
by listenaddresses='*'
and in the file pg_hba.conf has been added in the section of IPv4 host all all 0.0.0.0/0 md5
immediately followed by a restart of the service sudo service postgresql restart and voli.