7

I am facing problem while trying to start the server using the command

python manage.py runserver 0.0.0.0:8000

It is showing

C:\abc>python manage.py runserver 0.0.0.0:8000
Validating models...

0 errors found
Django version 1.4.9, using settings 'abc.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.

But cant access in browser via http://127.0.0.1:8000

It is showing :

Unable to connect

Firefox can't establish a connection to the server at 127.0.0.1:8000.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer's network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

But when I am trying the same by

python manage.py runserver 

it is working fine. i can access the application http://127.0.0.1:8000

What can be the issue.

curiousguy
  • 3,212
  • 8
  • 39
  • 71
  • Strange it works for me while trying `python manage.py runserver 0.0.0.0:8080` , not for `python manage.py runserver 0.0.0.0:8000` . Some issue with the port `8000` not sure if it is allocated by earlier `python manage.py runserver` which by default allocates `8000` port. Which I think should not be . – curiousguy Jan 27 '14 at 07:20
  • I'm not sure about the issue. You can access your site from http://0.0.0.0:8000 if you run your server as python manage.py runserver 0.0.0.0:8000 – Nagkumar Arkalgud Jan 27 '14 at 07:20
  • Have you tried turning it off and on again? Don't get me wrong - maybe port 8000 is in use by a crashed run server on your "external IP" – Thomas Schwärzl Jan 27 '14 at 07:26
  • If this is the case @init3 , then why `python manage.py runserver` is working fine , it is running on port `8000` , `http:\\127.0.0.1:8000` – curiousguy Jan 27 '14 at 07:28
  • binding 8000 to 0.0.0.0 (alias for e.g. 192.168.1.1) does not work. Binding 8000 to 127.0.0.1 (no alias) does work. Binding 8080 to 0.0.0.0 (e.g. 192.168.1.1) does work - not in use. That's why :) Check `netstat -tulpn | grep 8000` to see if port 8000 is still in use by your external IP – Thomas Schwärzl Jan 27 '14 at 07:32
  • 1
    Yes you are right @init3 tried this `C:\Users\15809>netstat -an Active Connections Proto Local Address Foreign Address State TCP 0.0.0.0:4105 0.0.0.0:0 LISTENING TCP 0.0.0.0:4728 0.0.0.0:0 LISTENING TCP 0.0.0.0:7163 0.0.0.0:0 LISTENING TCP 0.0.0.0:8000 0.0.0.0:0 LISTENING TCP 0.0.0.0:8000 0.0.0.0:0 LISTENING TCP 0.0.0.0:47001 0.0.0.0:0 LISTENING` – curiousguy Jan 27 '14 at 09:11
  • So I restarted my machine and those allocation of `8000 port` Binded with `0.0.0.0` by other external IP is gone and this command `python manage.py runserver 0.0.0.0:8000` is working fine for me . Thanks a lot :) – curiousguy Jan 27 '14 at 09:25
  • Posted "official answer" - maybe I'll get a little up vote? :) – Thomas Schwärzl Jan 27 '14 at 09:36
  • @ThomasSchwärlz: 0.0.0.0 is not an alias for 192.168.1.1. Rather, 0.0.0.0 is a wildcard to bind to all IP addresses that the machine has. – Lie Ryan Dec 09 '18 at 05:49

1 Answers1

9

It looks like Port 8000 is in use by your external IP. Please have a look if a process is running and kill it.

You can check the open ports with netstat -a. In Debian you get the PID with netstat -tulpn | grep 8000. The last line should display something like 1234/python. Now kill it with kill 1234.

Alternative you could restart your system ;-)

Thomas Schwärzl
  • 9,518
  • 6
  • 43
  • 69