Search code examples
djangopostgresqlamazon-web-servicesamazon-rds

Django is trying to authenticate Wrong user for AWS RDS and failing


I am hosting a postgresql database on AWS using the RDS service. I am trying to connect the django project to the aws database using the settings.py file in the django project. I keep getting the following error:

connection to server at "database-1.xxxxxx.us-east-1.rds.amazonaws.com" (xx.xxx.xx.xxx), port 5432 failed: FATAL: password authentication failed for user "local_user"

This error is unexpected because it should not be trying to authenticate the local_user as this is the user for my local postgres server, it should be trying to authenticate the user for the hosted database, which is completely different.

This is what my settings file looks like:

    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.environ.get('DATABASE_NAME'),
        'USER': os.environ.get('DATABASE_USER'),
        'PASSWORD': os.environ.get('DATABASE_PASSWORD'),
        'HOST': "database-1.xxxxxx.us-east-1.rds.amazonaws.com",
        'PORT': 5432
    }
}

I can't figure out what the issue seems to be. Any help will be appreciated!


Solution

  • I named the environment variable wrong so USER was none!