Django SSL Server
Django SSL Server is an SSL-enabled development server for the Django Framework, providing a `runsslserver` management command to serve projects over HTTPS during local development. It ships with a self-signed certificate for immediate use. The current version, 0.22, was released in December 2019. While primarily maintained by the community, recent pull requests indicate ongoing efforts to ensure compatibility with newer Django and Python versions. It is strictly intended for development and should never be used in production environments.
Common errors
-
ModuleNotFoundError: No module named 'sslserver'
cause The 'sslserver' application has not been added to your Django project's INSTALLED_APPS, or the package was not installed.fixEnsure `pip install django-sslserver` has been run and add `'sslserver'` to your `INSTALLED_APPS` list in `settings.py`. -
ERR_SSL_PROTOCOL_ERROR (browser error) or [SSL: CERTIFICATE_VERIFY_FAILED] (server error)
cause This usually indicates an issue with the SSL certificate and key, or the browser not trusting the self-signed certificate. It can also occur if the certificate/key files are not found or are corrupted.fixFor browser warnings, accept the self-signed certificate in your browser or install `sslserver/certs/development.crt` as a trusted certificate. If providing custom certificates, verify that the `--certificate` and `--key` paths are correct and the files are valid. -
Static files (CSS, JS, images) are not loading (404 errors) when using runsslserver.
cause The development server might not be configured to serve static files, especially if a third-party static file handler is active, or if using an older version of `django-sslserver` that had issues with static files.fixIf using an external static file handler, try running `python manage.py runsslserver --nostatic`. Ensure `DEBUG = True` and `STATIC_URL`, `STATICFILES_DIRS`, and `STATIC_ROOT` are correctly configured in `settings.py` for development.
Warnings
- breaking Django SSL Server is strictly for development purposes and MUST NOT be used in production environments. It lacks the security, performance, and robustness required for live applications.
- gotcha When using the default self-signed certificate, browsers will display security warnings (e.g., 'Your connection is not private'). This is expected behavior because the certificate is not issued by a trusted Certificate Authority.
- gotcha Version 0.22 officially supports Django up to 2.2 and Python up to 3.7. Using it with newer Django or Python versions might lead to compatibility issues or errors.
- gotcha When using third-party static file handlers (like WhiteNoise or `dj_static`), `django-sslserver` might not serve static files correctly, resulting in 404 errors.
Install
-
pip install django-sslserver
Imports
- sslserver
INSTALLED_APPS = [... 'sslserver', ...]
Quickstart
# settings.py
INSTALLED_APPS = [
# ... other apps
'sslserver',
]
# Terminal
# navigate to your Django project root (where manage.py is located)
# Then run the development server with SSL:
# python manage.py runsslserver
# Access your app at https://127.0.0.1:8000/