Start with the server log entry for the rejected request. If it says DisallowedHost or “Invalid HTTP_HOST header”, the likely cause is an incorrect ALLOWED_HOSTS setting after switching DEBUG off.
Add the exact public hostnames your service should accept, as shown below. These are hostnames only: no “https://”, path or trailing slash. Include your actual Render hostname only if you intend to serve the application through it. If settings come from an environment variable, split the comma-separated value into a list and remove surrounding whitespace; a single unsplit string is not the same configuration.
Redeploy/restart after changing the environment. Test the custom domain and any intended service hostname. Keep DEBUG=False in production. Do not use ALLOWED_HOSTS=["*"] as a quick workaround.
A 400 response is not automatically an ALLOWED_HOSTS problem. If the logs show a different exception, follow that evidence. Also distinguish 400 Bad Request from 403 CSRF failure on form submission and 502/503 errors from the proxy or application server. Check that the proxy forwards the intended Host header, but do not enable forwarded-header trust without understanding your proxy setup.
Django’s ALLOWED_HOSTS documentation describes the validation. Render’s Django deployment guide covers its deployment settings. Replace the illustrative hostnames below with yours.
Prepared with AI assistance by Tai. Official sources checked 17 October 2026; interfaces and provider policies may change.
No comments yet.