[Fixed]-Accessing django project in LAN systems

36πŸ‘

βœ…

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. πŸ™‚

πŸ‘€Babu

38πŸ‘

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)

πŸ‘€Ponytech

4πŸ‘

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.

3πŸ‘

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
πŸ‘€Adri

Leave a comment