Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

manage.py runserver

Tags:

python

django

I am running python manage.py runserver from a machine A when I am trying to check in machine B. The url I typed is http://A:8000/ .

I am getting an error like The system returned: (111) Connection refused

like image 469
sreekanth Avatar asked Apr 24 '11 05:04

sreekanth


People also ask

What does manage py Runserver do?

1) python manage.py runserver This command you'll probably run the most of all commands. It means to run a emulated server on your local computer. So, after running it, you can go to localhost:8000 or 127.0. 0.1:8000.

How do I change the Runserver port in Django?

Inside the commands folder open up the runserver.py script with a text editor. Find the DEFAULT_PORT field. it is equal to 8000 by default. Change it to whatever you like DEFAULT_PORT = "8080"


2 Answers

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

like image 195
Pol Avatar answered Oct 02 '22 05:10

Pol


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.

like image 44
Jason Webb Avatar answered Oct 02 '22 06:10

Jason Webb