3

So my site shows up fine with DEBUG = True, but I get a 200 server error when I change it to False. I've been reading around and saw that 500 errors are common but I can't find anything on a 200 error. My local_settings.py file doesn't have an ALLOWED_HOSTS area, so I put one in as well as my servers IP address, but still get the same issue. Here's my traceback.

[Thu May 16 16:21:10 2013] [error] /home/cleathers89/.envs/beak_mezz/lib/python2.7/site-packages/mezzanine/utils/conf.py:48: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.

I also looked into the conf.py file where it tells me the error is coming from, but I don't think I'm supposed to edit that. I'm a total noob to servers so any help would be much appreciated.

FDinoff
  • 30,689
  • 5
  • 75
  • 96
user2392322
  • 31
  • 1
  • 2

1 Answers1

5

ALLOWED_HOSTS has been been added in the version 1.5 "to prevent an attacker from poisoning caches and password reset emails with links to malicious hosts by submitting requests with a fake HTTP Host header"

Basically you only need to add the name of domains here which will be using the project.

Example:

ALLOWED_HOSTS = ['www.my-django-project.com', 'your-username.webfaction.com', ]
# ie. not the ip-address but the actual domain name

This is used only in production (that is why it shows up only when DEBUG is set to FALSE). As it is used in production settings, thus you will need to add the above in production_settings.py and not in local_settings.py

Link to documentation: https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts

Pratyush
  • 5,108
  • 6
  • 41
  • 63
  • 3
    In addition to this correct answer, with Mezzanine, if this is causing you an error, it's also an indication that you haven't correctly configured a site record in the admin, which you'll need to do. – Steve May 17 '13 at 21:00
  • In mezzanine, after the above change, I was getting this error: `ImportError: Could not import settings`. I'm not sure what @Stephen was talking about, but for myself with Mezzanine, I had to change line 25 in `manage.py` from `settings_module = "%s.settings" % PROJECT_DIRNAME` to `settings_module = "settings"`. This is because (I believe), Django 1.4/1.5 now works with the `manage.py` file one directory up, while Mezzanine has a flat structure (all files in the base project directory). After that change, everything worked fine. – Nate Aug 25 '13 at 18:34