简体   繁体   中英

Django; django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host, user, database

I'm a beginner and I've been creating a Django project. I'm trying to switch sqlite3 db to postgresql . But when I do make migrations , this error occurred.

django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host, user, database

I searched about this error. And some people checked pg_hba.conf file, but I have no idea where this file is.

Also when I created project before and did the same thing, there's no this error. Why is this error happening this time? What is the cause?

How can I fix this error?

Here is configuration part in settings.py

DATABASES = {
'default': {

    #elephantsql
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': os.environ.get('DATABASE_NAME', ''),
    'USERS': os.environ.get('DATABASE_USER', ''),
    'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
    'HOST': os.environ.get('DATABASE_HOST', ''),
    'PORT': os.environ.get('DATABASE_PORT'),
    }
}

Looks like a typo to me :
'USERS': os.environ.get('DATABASE_USER', ''),
should probably be:
'USER': os.environ.get('DATABASE_USER', ''),

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