How to access the local Django webserver from outside world


I followed the instructions here to run Django using the built-in webserver and was able to successfully run it using python runserver. If I access locally from the webserver, I get the Django page indicating it worked.

I realize the Django webserver is not a production server, but it’s important for me for testing purposes to be able to access it from the outside world — i.e. not from a web browser on the server, but from a different computer.

I tried:


but it did not work. I also tried using the IP instead (based on ifconfig) to access:


which did not work either.

The web server is running so it must be accessible from the outside, I’m just not sure how. I am running Linux with Apache, though I have not configured Django with Apache.

Any ideas on how to do this?

Asked By: user248237



You have to run the development server such that it listens on the interface to your network.


python runserver

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:

  • Stop the Apache server, so that port 80 is free.
  • Start the development server with sudo python runserver
Answered By: Felix Kling

Pick one or more from:

  • Your application isn’t successfully listening on the intended IP:PORT
    • Because you haven’t configured it successfully
    • Because the user doesn’t have permission to
  • Your application is listening successfully on the intended IP:PORT, but clients can’t reach it because
    • The server local iptables prevents it.
    • A firewall prevents it.

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.

Answered By: MattH

I’m going to add this here:

  1. sudo python runserver 80

  2. Go to your phone or computer and enter your computers internal IP (e.g into the browser.

At this point you should be connected to the Django server.

This should also work without sudo:

python runserver
Answered By: James111

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

  • sudo apt-get install python-pip
  • sudo pip install django

2) Ensure that security group in-bound rules includ http on port 80 for

  • configured through AWS console

3) Add Public IP and DNS to ALLOWED_HOSTS

  • ALLOWED_HOSTS is a list object that you can find in
  • ALLOWED_HOSTS = [“″,””]

4) Launch development server with sudo on port 80

  • sudo python runserver 0:80

Site now available at either of the following (no need for :80 as that is default for http):

  • [Public DNS] i.e.
  • [Public IP] i.e
Answered By: datavoredan

I had to add this line to in order to make it work (otherwise it showed an error when accessed from another computer)


then ran the server with:

python runserver

Also ensure that the firewall allows connections to that port

Answered By: Bonfix Ngetich

just do this:

python 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


you may have to edit the
add the following in the in the last line:


hope this will help…

Answered By: Joish

If you are using Docker you need to make sure ports are exposed as well

Answered By: Amjad Al Taleb


python runserver yourIp:8000

Answered By: Kashif

install ngrok in terminal

sudo apt-get install -y ngrok-client

after that run:

ngrok http 8000
ngrok http 

You need just to allow any hosts : :


Run your server :

python3 runserver

If you want to connect android app just add internet permission in AndroidManifest
It’s work for me 😉

Answered By: Abidi Mohamed

open terminal
type : ifconfig
check results of ifconfig command
use the inet IP .. should look like this.. or similar 192.168.x.x.

now runserver like you normally do but this time specify the inet IP
python3 runserver 192.168.x.x:8000 (replace the x with your inet)

Answered By: adrian stefan
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.