Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django accessing localhost from any machine connected to any network

I have a django project that I am running on localhost:8000 and that works fine. Now I want it to access from any machine that is connnected to other network.

Doing some google I found that I can do it by setting port forwarding from my router. I have a tplink router and I did the following setting:

Service Port:27015
IP Address: my_ip_address   # obtained by ifconfig
Protocol: All
Status: Enabled

Now I run my project with python manage.py my_ip_address:27015

But when I run with my_ip_address:27015 in url from another machine connected to another network I cannot view my site/page

Can anyone help me how to access my localhost outside the globe?

like image 244
varad Avatar asked Dec 15 '22 17:12

varad


1 Answers

You can not access localhost form outside; localhost servers will only respond on the localhost "device".

you need to start the server, in this case django, and have it bind to your local address (192.168, or 10., etc).

python manage.py runserver 0.0.0.0:8000

will have it bind to all available IP addresses on your machine.

Then you can port forward on your router to your local machine (disable any firewall for that port on your local machine)

like image 68
warath-coder Avatar answered Dec 28 '22 09:12

warath-coder