WebFaction
Community site: login faq

I'm trying to set the new ALLOWED_HOSTS setting parameter in my Django 1.5 app.

I tried 'localhost', '127.0..0.1', the server name and IP found in my.webfaction/ACCOUNT/Dashboard/Settings, but I still get a 500 error.

It only works when I set it to ['*'], which is not recommended.

What should I set it to?

asked 15 May '13, 03:36

jul
111610
accept rate: 0%


You should set that to the domains your Django app serves.

So, if your domain is example.com you would need to set it to:

ALLOWED_HOSTS = ['example.com'].

If you also serve your content from www.example.com you can either set it to...

ALLOWED_HOSTS = ['example.com', 'www.example.com']

or...

ALLOWED_HOSTS = ['.example.com']

... to accept example.com and all subdomains.

You can also add a 'username.webfactional.com' or 'django.username.webfactional.com' items, if you also serve your application from a webfactional subdomain.

You can see more about this new feature at the official documentation.

permanent link

answered 15 May '13, 07:43

iliasr ♦♦
2.1k14
accept rate: 35%

I've already read the doc, but I'm not sure what I should put: is that the server where my Django app is hosted? Or "the domains your Django app serves" is where I'm going to access my app from? In that case, how can I know? It's a web page, it can be accessed from anywhere...

(16 May '13, 01:46) jul

It should be set to include whatever domains/subdomains are attached to the site that is serving your Django application.

So, if your serving your site from example.com and www.example.com, you should set it as:

ALLOWED_HOSTS = ['example.com', 'www.example.com']

Be sure to restart your Apache after you change your settings.

(16 May '13, 13:10) seanf

I've been having this same issue once debug is turned off. I've tried doing what was mentioned above but it doesn't seem to work. Is it supposed to be added to local_settings.py? Would it make a difference if I were using a mezzanine set-up rather than a straight Django project?

(16 May '13, 23:42) LeJardin1982

@seanf: as written in my question, I tried the server name and IP, but I get an error.

(17 May '13, 00:39) jul

@LeJardin1982 it shouldn't matter, but this might not be the same problem you're having. Does setting the option to ["*"] help? If so, then it is the same issue.

(17 May '13, 00:39) waynek

Ok, it's the domain, not the server address, my mistake. Thanks.

(17 May '13, 00:45) jul

having ['myproj.com', '.myproj.com'] doesn't work for me - I'm using mezzanine and get a "sorry, an error ocurred" when accessing http://myproj.com, but everything's fine when I access http://www.myproj.com. Any advice?

(07 Jul '13, 21:16) foxwoods

foxwoods: Try ['myproj.com', 'www.myproj.com'] if this fails submit a support ticket.

(07 Jul '13, 23:31) johns

problem was overspecification, ['.myproj.com', '.myproj.com.'] works.

(08 Jul '13, 21:32) foxwoods
showing 5 of 9 show 4 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×16

question asked: 15 May '13, 03:36

question was seen: 21,671 times

last updated: 08 Jul '13, 21:32

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM