I’m seeing the following error when running my Django app on Heroku:
connection to server at "127.0.0.1", port 6000 failed: server does not support SSL, but SSL was required
In settings.py
, I have my DATABASES variable configured like this:
if env.get("DJANGO_DEVELOPMENT"):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"OPTIONS": {
"service": env.get("DATABASE_SERVICE"),
},
}
}
else:
DATABASES = {
"default": dj_database_url.config(
conn_max_age=500, ssl_require=True
)
}
However, I notice that the error page lists the DATABASES variable, and this includes sslmode': 'require
:
DATABASES
{'default': {'ATOMIC_REQUESTS': False,
'AUTOCOMMIT': True,
'CONN_HEALTH_CHECKS': False,
'CONN_MAX_AGE': 600,
'ENGINE': 'django.db.backends.postgresql',
'HOST': '127.0.0.1',
'NAME': 'db1',
'OPTIONS': {'sslmode': 'require'},
'PASSWORD': '********************',
'PORT': 6000,
'TEST': {'CHARSET': None,
'COLLATION': None,
'MIGRATE': True,
'MIRROR': None,
'NAME': None},
'TIME_ZONE': None,
'USER': 'zvchpwwqszbgax'}}
Have I configured something incorrectly? I assume that Heroku enables SSL for the attached Postgres database, and see it as “required” seems like the correct setting is enabled.