django-dbconn-retry
Patch Django to retry a database connection first before failing.
Decision gist · record as of 2026-08-14
Yes, if you run Django with load-balanced or pooled database connections (HAProxy, pgbouncer, Vault). The package solves a real operational problem with low friction and no dependencies. No known vulnerabilities. Active maintenance and permissive license. Not necessary if your database connections are stable and direct.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with no runtime dependencies.
- Active maintenance as of 2026-05-02, with recent repository activity (last commit 2026-08-10).
- Moderate popularity at top_15000 tier with ~92140 monthly downloads.
License · maintenance · safety
permissive license (permissive) — BSD License (permissive). Allows commercial use, modification, and distribution with minimal restrictions—only requires retaining copyright notice and disclaimer.
last release 2026-05-02 (104 days) · last repo commit 2026-08-10 · 83 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 92,140 downloads/mo, #13,474 on PyPI
Alternatives
Verify before relying
pip install django-dbconn-retry
# In settings.py, add to INSTALLED_APPS:
INSTALLED_APPS = [
'django_dbconn_retry',
# ...
]
# Optional: configure retry behavior
MAX_DBCONN_RETRY_TIMES = 1 # default
DBCONN_RETRY_DELAY = 0 # default
DBCONN_RETRY_BACKOFF = 1 # default- Whether the package works with all Django versions or has specific version constraints not listed in the fact sheet.
- Whether the monkeypatch approach has any known incompatibilities with other Django middleware or database backends.
- Performance impact of the retry mechanism under high-concurrency workloads.
What it is and what it does
django-dbconn-retry patches Django's database wrapper to handle closed TCP connections gracefully. When a database operation fails because the connection was already closed—a common issue when using load balancers like HAProxy or connection poolers like pgbouncer—the library automatically attempts to reconnect and retry the operation instead of immediately raising an OperationalError.
The package is configured via Django settings (MAX_DBCONN_RETRY_TIMES, DBCONN_RETRY_DELAY, DBCONN_RETRY_BACKOFF) and exposes Django Signals (pre_reconnect, post_reconnect) to allow other code to hook into the reconnection process. This is useful for scenarios like refreshing database credentials from Hashicorp Vault before reconnecting, or handling credential expiration in dynamic authentication systems.
Use it for
- Recover from transient connection drops caused by HAProxy or pgbouncer load balancers without raising exceptions to the application.
- Automatically refresh database credentials from Hashicorp Vault when a connection fails due to expired credentials.
- Reduce application crashes and improve resilience in environments with aggressive connection timeout policies.
- Implement graceful retry logic for database operations in microservices architectures with unstable network conditions.
- Handle connection state mismatches in high-availability database setups without explicit application-level retry code.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you run Django with load-balanced or pooled database connections (HAProxy, pgbouncer, Vault).
The package solves a real operational problem with low friction and no dependencies. No known vulnerabilities. Active maintenance and permissive license. Not necessary if your database connections are stable and direct.
Install
django-dbconn-retry on PyPI
Before you install
Low install friction with no runtime dependencies. Active maintenance as of 2026-05-02, with recent repository activity (last commit 2026-08-10). Moderate popularity at top_15000 tier with ~92140 monthly downloads.
License in practice
BSD License (permissive). Allows commercial use, modification, and distribution with minimal restrictions—only requires retaining copyright notice and disclaimer.
Quickstart
pip install django-dbconn-retry
# In settings.py, add to INSTALLED_APPS:
INSTALLED_APPS = [
'django_dbconn_retry',
# ...
]
# Optional: configure retry behavior
MAX_DBCONN_RETRY_TIMES = 1 # default
DBCONN_RETRY_DELAY = 0 # default
DBCONN_RETRY_BACKOFF = 1 # default
Verify before relying
- Whether the package works with all Django versions or has specific version constraints not listed in the fact sheet.
- Whether the monkeypatch approach has any known incompatibilities with other Django middleware or database backends.
- Performance impact of the retry mechanism under high-concurrency workloads.
Package facts
| License | permissive license permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 104 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 92,140 / month, #13,474 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: BSD LicenseOperating System :: POSIXProgramming Language :: Python :: 3 :: Only |
Evidence: django_dbconn_retry-0.3.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “django database connection retry”
- django-dbconn-retryAutomatically reconnects Django database connections when the…
- django-db-geventpoolProvides a gevent-based connection pool for Django's PostgreSQL…
- django-db-connection-poolProvides connection pooling for Django database backends (MySQL,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also reretry · retry · retrying · waiter · retry2 · pyramid-retry · django-db-connection-pool · django-valkey · bleak-retry-connector · retry-requests