Nginx, Django - Domain gives 400 (Bad Request) but reaching through IP Adress des work...

Posted May 2, 2020 7.4k views


I added the domain to allowed hosts already like that:

ALLOWED_HOSTS = ["", "*", ""]

This is how my nginx sites available file looks like:

server {
    listen 80;


I am really frustrated right now because I cant find the mistake here.
I tried a lot and would be really really grateful for an advice. Thanks

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.

Submit an Answer
2 answers

Hi @mendax23,

Please change the allowed hosts from

ALLOWED_HOSTS = ["", "*", ""]


ALLOWED_HOSTS += ["", "*", ""]

You need to use += rather than just = so that it appends everything after the first entry.

Please try with that and see if you would get the proper outcome.

Additionally, I noticed the same question has been answered here -

You may want to go through it, it might provide some other good suggestions.


  • Thanks for the quick answer.
    I already tried everything on that post and it does not work.

    The change to “+=” did not change anything.
    Have you another advice maybe.


Try server_name;

With this dot before it uses * and