Skip to main content

django-kamal-healthcheck

Django middleware that handles Kamal healthcheck requests.

The problem

kamal-proxy sends healthcheck requests to /up/ with a Host header that won't match your Django ALLOWED_HOSTS. The request hits Django's SecurityMiddleware or host validation and gets rejected before your app can respond, so kamal-proxy thinks the container is unhealthy.

The solution

HealthCheckMiddleware sits first in the middleware stack and intercepts healthcheck requests, returning a 200 OK response before any host validation or SSL redirect logic runs.

Installation

If you use uv:

uv add django-kamal-healthcheck

or

pip install django-kamal-healthcheck

Configuration

Add kamal_healthcheck to INSTALLED_APPS and put the middleware first in MIDDLEWARE:

# settings.py

INSTALLED_APPS = [
    "kamal_healthcheck",
    # ...
]

MIDDLEWARE = [
    "kamal_healthcheck.middleware.HealthCheckMiddleware",  # must precede SecurityMiddleware
    "django.middleware.security.SecurityMiddleware",
    # ...
]

That's it. Requests to /up/ will return a 200 OK plain text response.

Custom healthcheck path

The default path is /up/, matching kamal-proxy's default. To change it:

KAMAL_HEALTHCHECK_PATH = "/healthz/"

System checks

The app registers two Django system checks that run automatically:

  • kamal_healthcheck.W001: Warns if SECURE_SSL_REDIRECT = True and SecurityMiddleware is ordered before HealthCheckMiddleware. kamal-proxy handles SSL termination and does not follow redirects, so this combination causes healthcheck redirect loops.

  • kamal_healthcheck.W002: Warns if HealthCheckMiddleware is not the first entry in MIDDLEWARE. It must run before host validation and other security middleware.

Requirements

  • Python >= 3.10
  • Django >= 4.2

License

MIT

Metadata

Release files for django-kamal-healthcheck 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-kamal-healthcheck 0.1.0
File Size Uploaded Provenance
django_kamal_healthcheck-0.1.0.tar.gz 13.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-kamal-healthcheck 0.1.0
File Interpreter ABI Platform
django_kamal_healthcheck-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.8 kB

Release files / django_kamal_healthcheck-0.1.0.tar.gz

Download URL django_kamal_healthcheck-0.1.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a635041690f453cafa771e37b91875ae1b25d55d14ce63eb9955bca549425667
BLAKE2b-256 checksum
How to use checksums
006a0c174c84aa1e1dd7c4aae97c495e4b61916daed31bf54fb2d449d4da2c3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

Release files / django_kamal_healthcheck-0.1.0-py3-none-any.whl

Download URL django_kamal_healthcheck-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a6482aa9df00cb9de86cfe3d6c9e9fb4d7cc396f1705d9c7d9efedfbc850b53
BLAKE2b-256 checksum
How to use checksums
efd946849224a1229341b8bf48730ed6968fc8389ee4c26a069760e184d468cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

Security for django-kamal-healthcheck 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_kamal_healthcheck-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page