How do I connect to my Django local webserver using another device through ip address?

I created a dummy website using Django, python, HTML, CSS, and JavaScript recently. After completing it I tested the website by starting the server.

python3 runserver

I was able to open the website in a browser in the local machine using the link

Now, I want to connect to this server using my android device.

As my first step I started a hotspot on my android which I've connected my pc by wifi in order to bring the client and server in the same network.

Then I figured out the local IP address of my PC and I've switched off the firewall on my PC.

After doing that I ran the Django runserver command with this address,

python3 runserver

And just like before I am able to use the website without a problem in my local machine/PC. However, when I tried to connect to this with my mobile using the link,

Where is the IP address of the PC which I'm running as the current local server. I get a error message as

The site can't be reached refused to connect ERR_CONNECTION_REFUSED

I don't understand what I am doing wrong. Can someone let me know what I could do to fix this? Thanks.

You need to use the IP address of your computer in your local network (assuming your mobile device is on the same network as your desktop). On Linux and Mac you can check your IP with ifconfig or using ipconfig on Windows. localhost always refers to the current machine, i.e. localhost on your desktop points to your desktop and on your mobile device it points to your mobile device. That's why you can't access it - the app runs on your desktop not mobile.

Once you know the IP address of your computer you need to replace localhost with it. In my case the IP is so I use the following address to access my app:

1.Type in cmd (windows): ipconfig
2.Look for IP address IPV4: enter image description here
3. Type in URL search bar of your browser (example): 3000 is the port number that your react app is running on: enter image description here 4.Make sure that your mobile browser (Chrome is preferred) is on the latest update, my react app didn't load up for me because chrome wasn't updated.

Back to Top