I would like to run a Django server locally using a local IP.
I have localhost mapped here:
$ head -n 1 /etc/hosts
127.0.0.1 localhost
I have this chunk of code in my settings.py:
import os
ALLOWED_HOSTS = ['HERE.IS.MY.IP', 'localhost', '127.0.0.1']
print "ALLOWED_HOSTS: {}".format(ALLOWED_HOSTS)
In my mysql database I have this site table:
mysql> select * from django_site;
+----+--------------------+----------------+
| id | domain | name |
+----+--------------------+----------------+
| 1 | example.com | example.com |
| 5 | HERE.IS.MY.IP:8000 | projectsdb |
| 8 | 127.0.0.1:8000 | projectsdb |
| 9 | localhost:8000 | projectsdb |
+----+--------------------+----------------+
I run the server locally on 127.0.0.1:
$ python manage.py runserver 8000
ALLOWED_HOSTS: ['HERE.IS.MY.IP', 'localhost', '127.0.0.1']
Performing system checks...
# ...
Django version 1.10.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
If I go to this address http://HERE.IS.MY.IP:8000 it works. But of course I'd like to open it using a local IP such as http://localhost:8000 or http://127.0.0.1:8000. But this does not work. What am I missing?
ALLOWED_HOSTS = ['*']ALLOWED_HOSTS = ['*']in mysettings.py, now neitherhttp://HERE.IS.MY.IP:8000, norhttp://localhost:8000andhttp://127.0.0.1:8000work./etc/hostscompletely default or have you edited it? What error message do you get when you visit localhost:8000 ?/etc/hosts