This has been giving me problems for a few days now.
I have a django application that I am trying to connect to an elephantsql database.
My settings look like this:
DATABASES = {'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'name_provided_by_elephantsql',
'USER': 'name_provided_by_elephantsql',
'PASSWORD': 'xxxxxxxxxxxxxxxx',
'Host': 'ziggy.db.elephantsql.com',
'PORT': '5432',
}
}
Every time I try to makemigrations, I get the following error:
`django.db.utils.OperationalError: FATAL: Peer authentication failed for user "name_provided_by_elephantsql"
My pg_hba.conf file looks like this, but I have tried adding the credentials under IPv6, as well as changing several of the 'peer' to 'md5':
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
Then I tried to create a psql user with the same name, and created a database with it:
createdb -U name_provided_by_elephantsql -h ziggy.db.elephantsql.com -p 5432
And it returned:
createdb: error: could not connect to database template1: FATAL: no pg_hba.conf entry for host "174.45.58.218", user "name_provided_by_elephantsql", database "template1", SSL on
FATAL: no pg_hba.conf entry for host "174.45.58.218", user "name_provided_by_elephantsql", database "template1", SSL off
Restarted postgresql in between each attempt. I even tried purging postgresql. Lastly I tried this before reinstalling postgresql:
sudo rm -Rf /etc/postgresql /var/lib/postgresql
Can anyone tell me what I might be missing?