Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Django app from other computers

I am developing a web application on my local computer in Django.

Now I want my webapp to be accessible to other computers on my network. We have a common network drive "F:/". Should I place my files on this drive or can I just write something like "python manage.py runserver test_my_app:8000" in the command prompt to let other computers in the network access the web server by writing "test_my_app:8000" in the browser address field? Do I have to open any ports and how can I do this?

like image 327
Jamgreen Avatar asked Aug 28 '14 13:08

Jamgreen


People also ask

How do I access local Django server from another machine?

To connect to Django from a different machine, you must open port 80, 443 for remote access. Refer to the FAQ for more information on this. IMPORTANT: Making this application's network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks.


2 Answers

It is should be done with central system or server.

By default manage.py runserver will not give ip bind permission. So

Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).

If you want to check in your local machine then follow

python manage.py runserver 0.0.0.0:8000

Now go to your network computer and access your ip like 192.168.1.24:8000

Updated:

For Django version about 1.10 you should add your host to ALLOWED_HOSTS here

like image 52
Raja Simon Avatar answered Oct 29 '22 09:10

Raja Simon


Just add your own IP Address to ALLOWED_HOSTS

ALLOWED_HOSTS = ['192.168.1.50', '127.0.0.1', 'localhost']

and run your server python manage.py runserver 192.168.1.50:8000

and access your own server to other computer in your network

like image 11
YoKe Avatar answered Oct 29 '22 09:10

YoKe