Wgatail Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): <my server's ip>

425 views
Skip to first unread message

Ashish kataria

unread,
Jun 28, 2017, 2:02:29 AM6/28/17
to Wagtail support

I followed the basic steps to configure wagtail are as:

1. Install Wagtail

pip install wagtail

2. Start your site

wagtail start mysite

3. Set up the database

cd mysite
python manage.py migrate

4. Create an administrator account

python manage.py createsuperuser
python manage.py runserver
sign in at http://127.0.0.1:8000/admin/


Rather than http://127.0.0.1:8000/admin/
I want to access this with server's ip i.e.http://server-ip:8000/admin/

When I try accessing it gives an error page as: server IP address be in ALLOWED_HOSTS
How to insert my server ip address in ALLOWED_HOSTS settings. There is no settings.py file i see here. How to proceed?

Thanks.

Matthew Westcott

unread,
Jun 28, 2017, 10:32:37 AM6/28/17
to wag...@googlegroups.com
Hi Ashish,

In the standard Wagtail project structure, the settings can be found in [project_name]/settings/ and are split into dev.py (for settings used during development by `manage.py runserver`), production.py (for production sites running on a "proper" web server) and base.py (for settings common to both setups). In this case, [project_name]/settings/dev.py is the most appropriate place to put the ALLOWED_HOSTS setting.

Cheers,
- Matt

Karl Goetz

unread,
Jun 28, 2017, 8:22:45 PM6/28/17
to wag...@googlegroups.com, Matthew Westcott
Could future wagtail releases include 127/8 and localhost[.localdomain]
in ALLOWED_HOSTS in dev.py? With the new Django release requiring it be
set this seems like a reasonable time to add it.

(If it hasn't been done yet I'd be happy to raise a but to track this).

thanks,
kk

signature.asc

Matthew Westcott

unread,
Jun 30, 2017, 5:47:33 AM6/30/17
to wag...@googlegroups.com
Hi Karl,
According to https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts , localhost and 127.0.0.1 are accepted by default when DEBUG = True and ALLOWED_HOSTS isn't specified. In general, I'd like to keep to Django's defaults unless there's a good reason to differ.

Cheers,
- Matt

Karl Goetz

unread,
Jul 2, 2017, 7:52:02 PM7/2/17
to wag...@googlegroups.com, Matthew Westcott
On 30/6/17 19:47, Matthew Westcott wrote:
> Hi Karl,
> According to https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts , localhost and 127.0.0.1 are accepted by default when DEBUG = True and ALLOWED_HOSTS isn't specified. In general, I'd like to keep to Django's defaults unless there's a good reason to differ.

I just tested again and can't replicate the problem - my local test
environment is now allowing me to view localhost as expected. Not sure
what was going on there but it was definitely my environment.

thanks,
kk
signature.asc
Reply all
Reply to author
Forward
0 new messages