One common reason for this problem is an incorrect Django production configuration.
Django checks incoming hostnames to prevent certain types of host-header attacks. If your domain isn't included in the allowed hosts list, Django may reject the request.
Check the following:
- Configure
ALLOWED_HOSTS: Add your actual production domain and any required subdomains to the setting.
- Check the domain format: Don't include
https:// or URL paths in ALLOWED_HOSTS; use hostnames only.
- Review proxy settings: If Nginx or another reverse proxy handles HTTPS, verify the forwarded protocol configuration.
- Check CSRF trusted origins: Add the appropriate HTTPS origins to
CSRF_TRUSTED_ORIGINS when required.
- Review Django logs: Check the application logs for
DisallowedHost or other configuration errors.
- Verify production settings: Make sure
DEBUG is disabled and sensitive settings are not exposed publicly.
Avoid using ALLOWED_HOSTS = ['*'] as a permanent solution. Configure only the hostnames your application actually needs.