Serve multiple Django applications with Nginx and Gunicorn using multiple domains

As I was following this tutorial on how to Serve multiple Django applications with Nginx and Gunicorn using multiple domains ( )

When accessing the site via my subdomain, my site is not working. I’m getting the following error

Invalid HTTP_HOST header: `''`. You may need to add '' to ALLOWED_HOSTS.

I have already added the same on allowed hosts and restarted nginix and Gunicorn.

I had another site which is already running with no issues. Droplet IP is being used for both domains.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
June 28, 2023


there are a couple of possibilities on the origin of the error,

You have not showed what you have inside your Django file, but I assume you have not configured the ALLOWED_HOSTS variable as you should have. This is how it should look like:


Also, make sure to restart the Nginx service after doing so. The settings file is loaded to memory, so if you make changes to it, you need to restart the server.

systemctl restart gunicorn and systemctl restart nginx

Bobby Iliev
Site Moderator
Site Moderator badge
June 28, 2023

Hi there,

It sounds like that your Nginx configuration might be the issue if it is serving the contents of only one of the applications.

Can you share both of the Nginx server blocks that you have for each of the two websites? You need to make sure that the reverse proxy rules for each of the sites is pointing to the correct web socket.

Also, can you verify that both of the Gunicorn services are up and running?

Would you mind also sharing the ALLOWED_HOSTS definition for each site as well?



Thank you all, I was able to fix it by redirecting to 

I used this tut here

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel