R
Railway6mo ago
Tim

Logs filled with errors due to django allowed hosts settings

My issue is similar to https://discord.com/channels/713503345364697088/1172062119710171176/1172063615537385504 My logs are filled with stuff like this:
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
ERROR Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
ERROR Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '0.0.0.0:8052'. You may need to add '0.0.0.0' to ALLOWED_HOSTS.
...
ERROR Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'www'. You may need to add 'www' to ALLOWED_HOSTS.
ERROR Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '35.204.95.109:8052'. You may need to add '35.204.95.109' to ALLOWED_HOSTS.
The site works fine, but it makes monitoring actual errors rather annoying. How to fix this?
10 Replies
Percy
Percy6mo ago
Project ID: a9861a99-1c51-4b34-8970-6e92d5cd7f47
Tim
Tim6mo ago
a9861a99-1c51-4b34-8970-6e92d5cd7f47
Brody
Brody6mo ago
add it to your allowed hosts?
Tim
Tim6mo ago
Sounds like a bad idea (security-wise) to add ip addresses that are unknown to me to the allowed-hosts setting. Why is railway trying to host my app on other domains than the one that is specified?
Brody
Brody6mo ago
because your app sits behind a proxy
Tim
Tim6mo ago
Do you know if there is a complete list of ips that belong to railway that may be used?
Brody
Brody6mo ago
they would only be local ip address
Tim
Tim6mo ago
As can by seen in my logs, and the linked thread, that is not the case. For example 35.204.95.109
Brody
Brody6mo ago
that's a gcp address, nothing to worry about there
Tim
Tim6mo ago
Sure, but it seems undesirable that I either need to disable the allowed hosts security setting or that I need to whitelist arbitrary GCP hosts that pop-up in my logs to prevent my logs being filled with this error.