python manage.py runserver The runserver command is a built-in subcommand of Django's manage.py file that will start up a development server for this specific Django project.
You have to run the development server such that it listens on the interface to your network.
E.g.
python manage.py runserver 0.0.0.0:8000
listens on every interface on port 8000.
It doesn't matter whether you access the webserver with the IP or the hostname. I guess you are still in your own LAN.
If you really want to access the server from outside, you also have to configure your router to forward port e.g. 8000
to your server.
Check your firewall on your server whether incoming connections to the port in use are allowed!
Assuming you can access your Apache server from the outside successfully, you can also try this:
80
is free.sudo python manage.py runserver 0.0.0.0:80
I had to add this line to settings.py in order to make it work (otherwise it showed an error when accessed from another computer)
ALLOWED_HOSTS = ['*']
then ran the server with:
python manage.py runserver 0.0.0.0:9595
Also ensure that the firewall allows connections to that port
Pick one or more from:
So, you can check that your application is listening successfully by running lsof -i
as root on the machine and look for a python
entry with the corresponding port you've specified.
Non-root users generally cannot bind to ports < 1024.
You'll need to look at iptables -nvL
to see if there's a rule that would prevent access to the ip:port that you are trying to bind your application to.
If there is an upstream firewall and you don't know much about it, you'll need to talk to your network administrators.
just do this:
python manage.py runserver 0:8000
by the above command you are actually binding it to the external IP address. so now when you access your IP address with the port number, you will be able to access it in the browser without any problem.
just type in the following in the browser address bar:
<your ip address>:8000
eg:
192.168.1.130:8000
you may have to edit the settings.py add the following in the settings.py in the last line:
ALLOWED_HOSTS = ['*']
hope this will help...
For AWS users.
I had to use the following steps to get there.
1) Ensure that pip and django are installed at the sudo level
2) Ensure that security group in-bound rules includ http on port 80 for 0.0.0.0/0
3) Add Public IP and DNS to ALLOWED_HOSTS
4) Launch development server with sudo on port 80
Site now available at either of the following (no need for :80 as that is default for http):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With