﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34389	Django not closing database connections on ASGI application after an upgrade to 4.1	vsobotka	nobody	"We just upgraded Django from version 2.2.12 to version 4.1.7. We are using a basic ASGI app config
{{{
os.environ.setdefault(""DJANGO_SETTINGS_MODULE"", ""Landia.settings"")
django.setup()
application = get_default_application()
}}}
We are on Heroku, with Heroku Postgres version 12.14, and we use psycopg2-binary version 2.9.5. We also use Gunicorn 20.1.0, and Uvicorn 0.20.0.

Database is connected
{{{
DATABASES['default'] = dj_database_url.config(conn_max_age=0)
}}}

Since we deployed to production, we have started to experience a database connection buildup, quickly using up the whole pool of connection allowed by Postgres. A few minutes after the deploy we only get exception about no available connections.

We tried upgrading Django to 4.2b1, and Psycopg 3, but the issue still persisted. Now we tried downgrading Django to 3.1.8, and the connections are at their usual level, not being used up at all, with everything else but Django on a different version. This leads me to believe Django is not closing connections, but it could be due to an issue with our setup.

I would greatly appreciate any help regarding this issue, as this is a production blocker for us, at least for 4.1."	Bug	closed	Uncategorized	4.1	Normal	needsinfo			Unreviewed	0	0	0	0	0	0
