283
The error log is straightforward. As it suggested,You need to add 198.211.99.20 to your ALLOWED_HOSTS
setting.
In your project settings.py file,set ALLOWED_HOSTS
like this :
ALLOWED_HOSTS = ['198.211.99.20', 'localhost', '127.0.0.1']
For further reading
read from here.
7
settings.py
ALLOWED_HOSTS = ['*'] // if you are in dev or docker
Edited
Ok guys, dont do this in production if you are not using docker, just put the IP addr.
Grettings
- [Django]-Disable a method in a ViewSet, django-rest-framework
- [Django]-Get the list of checkbox post in django views
- [Django]-Passing STATIC_URL to file javascript with django
2
In your project settings.py file,set ALLOWED_HOSTS like this :
ALLOWED_HOSTS = ['62.63.141.41', 'namjoosadr.com']
and then restart your apache. in ubuntu:
/etc/init.d/apache2 restart
- [Django]-How to specify an IP address with Django test client?
- [Django]-Does django with mongodb make migrations a thing of the past?
- [Django]-Django change default runserver port
1
You can add ALLOWED_HOSTS
to your settings file or env
file:
ALLOWED_HOSTS = [".localhost", "127.0.0.1", "[::1]"]
- [Django]-Django staticfiles not found on Heroku (with whitenoise)
- [Django]-How to display the current year in a Django template?
- [Django]-How to solve "Page not found (404)" error in Django?
0
if no other answer work you can try modifying manage.py and add this three lines
from django.utils.regex_helper import _lazy_re_compile
import django.http.request
django.http.request.host_validation_re = _lazy_re_compile(r"[a-zA-z0-9.:]*")
to end up having something like this:
import os
import sys
from django.utils.regex_helper import _lazy_re_compile
import django.http.request
django.http.request.host_validation_re = _lazy_re_compile(r"[a-zA-z0-9.:]*")
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project01.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
as it is explained in this post: How to Solve "The domain name provided is not valid according to RFC 1034/1035" in Django during Development
- [Django]-Jquery template tags conflict with Django template!
- [Django]-How do you detect a new instance of the model in Django's model.save()
- [Django]-Django multiple template inheritance – is this the right style?
0
I was testing my Django app on minikube
and because of the probes, it was failing with the following error:
Invalid HTTP_HOST header: '10.244.0.8:8080'. You may need to add '10.244.0.8' to ALLOWED_HOSTS.
Bad Request: /
I added the httpHeaders
in my probes and it worked after that.
Before:
livenessProbe:
httpGet:
path: / # Replace with an endpoint that returns a 200 status code if the app is healthy
port: 8080
initialDelaySeconds: 10 # Delay before the first probe is executed
periodSeconds: 10 # How often to perform the probe
readinessProbe:
httpGet:
path: / # Replace with an endpoint that indicates readiness
port: 8080
initialDelaySeconds: 5 # Delay before the first probe is executed
periodSeconds: 5 # How often to perform the probe
After:
livenessProbe:
httpGet:
path: / # Replace with an endpoint that returns a 200 status code if the app is healthy
port: 8080
httpHeaders:
- name: Host
value: localhost
initialDelaySeconds: 10 # Delay before the first probe is executed
periodSeconds: 10 # How often to perform the probe
readinessProbe:
httpGet:
path: / # Replace with an endpoint that indicates readiness
port: 8080
httpHeaders:
- name: Host
value: localhost
initialDelaySeconds: 5 # Delay before the first probe is executed
periodSeconds: 5 # How often to perform the probe
- [Django]-How to convert JSON data into a Python object?
- [Django]-Django Multiple Authentication Backend for one project
- [Django]-How do I POST with jQuery/Ajax in Django?