question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not respecting Django's CONN_MAX_AGE database setting

See original GitHub issue

Hi, I’m using uvicorn with gunicorn. I have assigned CONN_MAX_AGE setting a value say 300 but its closing the connection instantly after completing the request.

My gunicorn configuration is like,

bind = ‘0.0.0.0:8000’ workers = 3 secure_scheme_headers = {‘X-FORWARDED-PROTO’: ‘https’} reload = True errorlog = ‘-’ loglevel = ‘debug’ worker_class = ‘uvicorn.workers.UvicornWorker’

And i’m running the following command to start the server,

gunicorn -c gunicorn.conf.py myproject.asgi:application

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
patrik7commented, Apr 22, 2020

I do not think this is a uvicorn issue.

I this this provides some more light: https://github.com/benoitc/gunicorn/issues/996 although I was not able to solve the problem yet.

0reactions
tomchristiecommented, Jul 6, 2019

Not sure, but this needs raising on channels or django or something - its not a uvicorn issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django CONN_MAX_AGE is set to 0 but connection remains ...
I have a problem where old connections stay open in idle state in the db. My request is: MyTable.objects.all().first().id. I use the following...
Read more >
Reduce no. of DB connection with Django - Medium
Solution: So we changed the settings like the following and our concurrent connection number changes drastically. 'CONN_MAX_AGE': 0.
Read more >
Settings - Django documentation
Here's a list of settings available in Django core and their default values. ... When set to True , if the request URL...
Read more >
Databases | Django documentation
To enable persistent connections, set CONN_MAX_AGE to a positive number of seconds. ... Django needs the following parameters for its database connections:.
Read more >
Django: CONN_MAX_AGE persists connections, but doesn't ...
7 and Postgres 9.3 on Ubuntu 14.04 LTS. At any given time, the site gets about ~250 simultaneous connections to the PostgreSQL database,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found