简体   繁体   中英

Cannot connect ElephantSQL database to django

I am trying to connect elephant sql service to django. I configured db settings in settings.py.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'test_db1',
        'USER': 'xxxxx',
        'PASSWORD': 'xxxxxxxxxxxxxxxxxxxx',
        'HOST': 'arjuna.db.elephantsql.com',
        'PORT': ''
    }
}

But It gives an error when I make migrations.

RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': connection to server at "heffalump.db.elephantsql.com" (50.18.63.64), port 5432 failed: FATAL:  no pg_hba.conf entry for host "123.231.123.61", user "hlcreaar", database "test_db2", SSL on
connection to server at "heffalump.db.elephantsql.com" (50.18.63.64), port 5432 failed: FATAL:  no pg_hba.conf entry for host "123.231.123.61", user "hlcreaar", database "test_db2", SSL off

I tried adding port number 5432, but still it doesn't work. Can someone help me to fix this error?

I currently run my connection as follows,

DATABASES = {

     'default': {

         'ENGINE': 'django.db.backends.postgresql_psycopg2',

         'NAME': 'test_db1',

         'USER': 'test_db1',

         'PASSWORD': '************************',

         'HOST': 'arjuna.db.elephantsql.com',

         'PORT': '5432',

     }
 }

Notice im using psycopg2. Name and User are the same.

The error is showing this host, "heffalump.db.elephantsql.com" Did you change the Database at some point? If you did, this might be the problem, and you probably need to do some work with the migrations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM