Reputation: 26678
I used django and developed a site which is working fine, and its about to move to production and ready for deployment in a couple of weeks.
So before moving to production, i want to share the site with some of my employees to check the functionality and something else. Actually their systems are connected in LAN with mine.
So my system IP address is something like 192.168.12.135
, when we run run django development server its runs at localhost:8000
, i mean with the system IP address and with a port 8000
like 192.168.12.135:8000
right.
So i had shared them the project site link as 192.168.12.135:8000
, but when they tried on the systems which are connected in LAN, it is not accessible and displaying an error Server not found
.
I tried the above same way because recently i used python web.py
framework and developed a minimal site , and when we run the server, it by default runs as localhost:8080
, and when i accessed this link from others system that are connected in LAN with mine as 192.168.12.135:8000
, its working fine and is accessible.
So can anyone please let me know
1. How to access the site on the systems that are connected in LAN before moving to production(in some real servers like apache, nginx etc.,).
2. Basically i am new to web developing and this is my first site developed in python, so
i don't know more about servers and deploying a project. So can anyone please let me know
the detailed information about deploying django on different servers
(First of all i am looking for a solution for 1st problem
(Accessing in LAN before moving to
production))
Upvotes: 19
Views: 30801
Reputation: 271
On windows I did everything you said but one thing was missing at my end to connect through Wi-Fi..
In settings.py:
ALLOWED_HOST = ['*']
Put Network profil in Private mode:
Windows > Settings > Network & Internet > Wi-Fi > (Click on_your_network) > In Network profil select: Private
Exemple: Run your server on the port 8000:
python manage.py runserver 0.0.0.0:8000
Then to access to the server with your other devices connected to the same network, enter the IPv4's server address with the your port (here 8000)
Exemple, if the IPv4's server address is 192.168.20.26 put the folling text directly in your browser:
192.168.20.26:8000
Upvotes: 3
Reputation: 81
In your settings.py change ALLOWED_HOSTS to
ALLOWED_HOSTS = ['*']
Run your server by entering the following command
python manage.py runserver 0.0.0.0:8000
In order to access the project from another device enter the IP address of the server followed by the port number, which is 8000 in this example.
Upvotes: 4
Reputation: 1684
If you run
python manage.py runserver 0.0.0.0:8000
your development server will be available on port 8000 to anyone on your LAN and on localhost as well (and it does not depend on your ip address)
Upvotes: 38
Reputation: 2598
You need to explicitly tell the development server to run on your IP rather than localhost
.
Try python manage.py runserver your_ip:port
.
Though it'll be accessible if you're running through apache or any other webservers other than the development server.
And to your 1st question, I would advice you to host and use a local apache server rather than using development server. Doing so, you can foresee the issues you'll be facing when moving to production.
And to 2nd, there are plenty of resources available configuring Django with different servers. Hail Google. :)
Upvotes: 36