1
votes

I get Bad Request (400) on my localhost when my DEBUG = False. Even I configured ALLOWED_HOSTS. I have been searching all over stackoverflow but still can't find the source of the problems.

DEBUG = False

ALLOWED_HOSTS = ['localhost','127.0.0.1']
1
It should work with just localhost. What version of Django are you using? - Jesse
I am using Django==1.10.5 - sdg
I'm thinking the 400 is coming from something else and isn't related to the ALLOWED_HOSTS, because your config is right. Look at this, maybe it helps - Jesse
That's what I thought too but it is clear that the bad request only appears when the DEBUG = False. I checked on that link but they don't answer my issue. - sdg
Try making a new, fresh project and just change those two configs and see if it works. That rules out any issues from your python or django installs. If that doesn't work, see if any middlewares you've installed are causing the problem. Commenting out things in your config is a surprisingly effective way to narrowing down a problem like this. - Jesse

1 Answers

0
votes

Try adding '*' to the list just in case and see if that helps.