[Django]-Manage.py runserver

176πŸ‘

You can run it for machines in your network by

./manage.py runserver 0.0.0.0:8000

And than you will be able to reach you server from any machine in your network.
Just type on other machine in browser http://192.168.0.1:8000 where 192.168.0.1 is IP of you server… and it ready to go….

or in you case:

  1. On machine A in command line ./manage.py runserver 0.0.0.0:8000
  2. Than try in machine B in browser type http://A:8000
  3. Make a sip of beer.

Source from django docs

πŸ‘€Pol

24πŸ‘

You need to tell manage.py the local ip address and the port to bind to. Something like python manage.py runserver 192.168.23.12:8000. Then use that same ip and port from the other machine. You can read more about it here in the documentation.

πŸ‘€Jason Webb

6πŸ‘

I was struggling with the same problem and found one solution. I guess it can help you. when you run python manage.py runserver, it will take 127.0.0.1 as default ip address and 8000. 127.0.0.0 is the same as localhost which can be accessed locally. to access it from cross origin you need to run it on your system ip or 0.0.0.0. 0.0.0.0 can be accessed from any origin in the network.
for port number, you need to set inbound and outbound policy of your system if you want to use your own port number not the default one.

To do this you need to run server with command python manage.py runserver 0.0.0.0:<your port> as mentioned above

or, set a default ip and port in your python environment. For this see my answer on
django change default runserver port

Enjoy coding …..

πŸ‘€Amrendra

4πŸ‘

Just in case any Windows users are having trouble, I thought I’d add my own experience. When running python manage.py runserver 0.0.0.0:8000, I could view urls using localhost:8000, but not my ip address 192.168.1.3:8000.

I ended up disabling ipv6 on my wireless adapter, and running ipconfig /renew. After this everything worked as expected.

πŸ‘€benrules2

3πŸ‘

in flask using flask.ext.script, you can do it like this:

python manage.py runserver -h 127.0.0.1 -p 8000

πŸ‘€wuxueqian

2πŸ‘

For people who are using CentOS7, In order to allow access to port 8000, you need to modify firewall rules in a new SSH connection:

sudo firewall-cmd --zone=public --permanent --add-port=8000/tcp
sudo firewall-cmd --reload
πŸ‘€Ernie

1πŸ‘

I had the same problem and here was my way to solve it:

First, You must know your IP address.
On my Windows PC, in the cmd windows i run ipconfig and select my IP V4 address. In my case 192.168.0.13

Second as mention above: runserver 192.168.0.13:8000

It worked for me.
The error i did to get the message was the use of the gateway address not my PC address.

πŸ‘€alvaro562003

1πŸ‘

First, change your directory:

cd your_project name

Then run:

python manage.py runserver
πŸ‘€ Vaibhav

0πŸ‘

Ok just came across this post this is a little off topic but hopefully explains a few things, The IP 127.0.0.1 points to your network card so any traffic that you cause to go to that IP address will not leave your computer.

For example modern network cards in laptops for example will not even give you that IP if you are not connected to a wifi or cabled network so you’ll need to be connected at least to activate the card.

If you need to run multiple servers on the same machine but want to access them with a domain then you have a couple of options

  1. edit your computers host file to define the domain and what IP it goes to
  2. use a DNS Alias I set up using a cname record years ago *.local.irishado.com will point to 127.0.0.1

so for example these three domains will point to your local machine

will all point to your local machine then in python projects you will need to edit the projects setting file ALLOWED_HOSTS property to hold the domain it will accept

ALLOWED_HOSTS = [β€˜site1.local.irishado.com’]

πŸ‘€IrishAdo

Leave a comment