0 votes
1 view
in Python by (47.8k points)

I am new to Django-1.6. When I run the Django server with DEBUG = True, it's running perfectly. But when I change DEBUG to False in the settings file, then the server stopped and it gives the following error on the command prompt:

CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.

After I changed ALLOWED_HOSTS to ["",], in the browser I get the error:

Bad Request (400)

Is it possible to run Django without debug mode?

1 Answer

0 votes
by (107k points)

The ALLOWED_HOSTS list should contain fully qualified hostnames, not URLs. Leave out the port and the protocol. If you are using, I would add localhost to the list too:

ALLOWED_HOSTS = ['', 'localhost']

You could also use * to match any host:


Welcome to Intellipaat Community. Get your technical queries answered by top developers !