How to proper setup ALLOWED_HOST to allow other machine in the network access the web

Django server in machine TestPC-A , at

I want it accessible from the computer in the same network

what I have configured


ALLOWED_HOSTS = ["", "localhost", "TestPC-A" , "", ""]

and this which i am not sure if this is necessary:


2. runserver.bat

@echo off
REM Activate virtual environment in the current terminal session and run server
cmd /k ".venv\Scripts\activate && python runserver_plus --cert-file cert.pem --key-file key.pem"

I have tried to add following in Windows hosts file C:\Windows\System32\drivers\etc\hosts    TestPC-A

I restart the server, and the web page is not loaded at another computer's web browser https://TestPC-A:8000/

What else that I need to set?

For posterity. To make your development server viewable to other machines on the network.

Suppose you have two machines machine A and machine B. Connect both machines to a common network (may even be your mobile phone’s wifi).

If machine A will be your server i.e. machine A is the machine where your source code has been all this while and machine A is where you have been running command:

python runserver

Check the IP address machine A was assigned on this network. [stackoverflow] Add this IP address to Django settings ALLOWED_HOSTS [django-docs] list so that Django will allow the machine to host it.

If the IP address is for example, add this to ALLOWED_HOSTS and now run the command:

python runserver # <—- runserver on port 7000 on this host on this network

Since machine B is connected to the same network as machine A, use any http-client (even your internet browser can serve) on machine B to connect to machine A i.e. your server using the socket address [1].

[1] We will use this socket address because the application is running on machine A which is at IP address on the network and the application is running on port 7000.

What I have done:

  1. ALLOWED_HOSTS = ["*"]
  2. runserver
  3. Important: add inbound rule at firewall, allow the connection applies to domain,private,public, TCP ThePort
Back to Top