Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect refused in response to Django runserver

Working my way through a Django tutorial, I have run django-admin startproject mysite. Now I cannot get the next step to work.

$ python manage.py runserver

>>>
$

where the blank line is where Ctrl-C was entered to break the loop. The >>> was the prompt I defined for the virtualenv. In other words, no output.

Most importantly, I get a connection refused error when connecting to http://127.0.0.1:8000. I do not get the the "'Welcome to Django' page, in pleasant, light-blue pastel" as described in the tutorial.

For other commands python manage.py works correctly. For example:

$ python manage.py check
System check identified no issues (0 silenced).

$ python manage.py shell --command 'import sys; print(sys.version)'
3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)]

$/ python manage.py shell --command 'import django; print(django.__version__)'
1.11.2

I am at loss for how explore further. I have tried:

  1. Using multiple browsers
  2. Varying the IP and port, including using LOCALHOST.
  3. Turning off the proxy
  4. Consulting other Stack Overflow, such as here and here
  5. Rebooting my computer
  6. Exploring Chrome's log's. Perhaps someone else can get something valueable out of these: Request Headers & Timing Diagram.

I am at loss for other steps to debug this problem.

like image 355
Mike Ulm Avatar asked Jun 08 '17 19:06

Mike Ulm


1 Answers

If you didn't change something in the settings.py you should enter the service in

localhost:8000

Using the same machine where you are runing the server.

If you want to enter from another computer in the same network you should use

$ python manage.py runserver 0.0.0.0:8000

And change your "allowed hosts" to the ip of your computer or to *

like image 98
Javier Campos Avatar answered Oct 23 '22 11:10

Javier Campos