Solved: DisallowedHost – Invalid HTTP_HOST header

This error is related to “Installing Django and Django-REST Framework on ubuntu” , if you have Django application / server running on local ubuntu host as,

$ python runserver

Then this server is started with binding to your local loopback IP address and default port as,

Starting development server at

Now, when you decide to use your IP address instead of local loopback and also change the port, you can start the webserver as,

$ python runserver

Considering, your IP address is “” (it can be different in your case) and port you want to use as “8080” ( This also can be different as you want)

Now, the server will get started but when you visit in browser as, you may see an error as,

DisallowedHost at /
Invalid HTTP_HOST header: ‘’. You may need to add ‘’ to ALLOWED_HOSTS.

Request Method:GET
Request URL:
Django Version:3.0.7
Exception Type:DisallowedHost
Exception Value:Invalid HTTP_HOST header: ‘’. You may need to add ‘’ to ALLOWED_HOSTS.

Solution :

Open YOUR_PROJECT/ and add the IP address ( in our case as,


and restart the server as,

$ python runserver

Now, if you visit the URL in browser , you should not see the error.

How to remove index.php from URL in... x
How to remove index.php from URL in CodeIgniter using .htaccess

1 thought on “Solved: DisallowedHost – Invalid HTTP_HOST header”

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development, Debugging and Performance Tools Development and Build Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web Design and Development Website Hosting Wordpress Yocto Embedded Linux