Django Tutorial: Runserver not working - python

I am starting to dabble with Django, and am having issues with the tutorial (https://docs.djangoproject.com/en/1.7/intro/tutorial01/)
I have successfully installed the framework. After running the migrate command, and starting the server with this command:
python manage.py runserver
Powershell outputs:
System check identified no issues (0 silenced).
November 27, 2014 - 16:32:54
Django version 1.7.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
So everything seems to be working fine. The tutorial tells me that:
Now that the server’s running, visit http://127.0.0.1:8000/ with your
Web browser. You’ll see a “Welcome to Django” page, in pleasant,
light-blue pastel. It worked!
But when I go to that link, I get the following message show up on my browser:
ERROR
The requested URL could not be retrieved
While trying to retrieve the URL: http://127.0.0.1:8000/
The following error was encountered:
Connection to 127.0.0.1 Failed The system returned:
(111) Connection refused The remote host or network may be down. Please try the request again.
Your cache administrator is root.
I am new to web development so I apologize for asking a rookie mistake, I just can't seem to find this issue with the django tutorial online, so I must be pulling a seriously rookie move!
Thanks in advance!

Maybe the problem is proxy? Look for this.

Related

On a django site I am getting socket cluster error

Not Found: /socketcluster/
[06/Aug/2020 21:45:44] "GET /socketcluster/ HTTP/1.1" 404 3181
this happens every 61 secounds while I am running the django webserver, using "python3 manage.py runserver". I am very new to web development and have no clue what this is or means, any help is appreciated.
P.S. Do I need a db to handle requests for the web server
This is happening for me as well. I'm still looking into the issue and I'll update this when I have a better answer, but I've found a temporary solution.
If you start the local Django server on a different port than the default 8000, the pesky requests go away:
python manage.py runserver 8001
Maybe some other process currently running thinks there's a socketcluster server active on post 8000, or something hidden in my codebase.
I had this problem and it turned out to be a recently installed chrome extension.

Django site cant be reached

I run the server in c9 (django workspace). There were no errors and it said
Starting development server at http://127.0.0.1:8000//.
However, when i open this site it says
This site can’t be reached
127.0.0.1 refused to connect.
Can anyone help me fix this issue
127.0.0.1 is your local computer, not the c9 instance. The docs refer to a unique URL for each app, like: http://<workspacename>-<username>.c9users.io:8081
So, try using runserver like this: python manage.py runserver $IP:$PORT
You can then look in your browser tab for the server address that you can see your app running on, which will be similar to the one above. You'll use that when testing instead of localhost or 127.0.0.1.
Check out the Django guide on their site for more details.
In the documentation says that you use a URL they give to you (not localhost) to access the server
Use the Share button on the top to figure out the URLs of running Application and the Preview.
See https://docs.c9.io/docs/run-an-application#section--pre-view-your-application

How to fix the connection error in django

I have created a new project in django. when I run python manage.py runserver, I am getting the msg in command prompt like below.
/var/www/samplepro/myapp$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
March 26, 2015 - 10:52:31
Django version 1.7.7, using settings 'myapp.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
when I test in browser, I am getting the page can't be displayed error. Can anyone help me to do get the django page.
You stated that you are running the server on Ubuntu while you are trying to connect it from another PC running Windows. In that case, you should replace the 127.0.0.1 with the actual IP address of Ubuntu server (the one you use for PuTTY).
I am also developing in a virtual machine.
Use ifconfig to figure out the IP address that has been assigned to your virtual machine.
Then start the server with:
python manage.py runserver <IP>:8000
Of course you could also use a different port instead of 8000. Then use that address and port in your host browser to access your server.
Note: At least in my VM, the virtual machine gets a new address from time to time, so check that in case you have trouble starting your server with the same command.
If this does not help, check your hosts file as mentioned in one of the comments.

c9.io Error: You don't have permission to access that port

So i was doing a django tutorial this weekend using the Cloud9 IDE on their web app c9.io. All is good and dandy until i get to the piece of running the server python manage.py runserver
You would think that it would work fine but i keep on getting this stuff.
python manage.py runserver
Validating models...
0 errors found
February 22, 2014 - 23:42:03
Django version 1.5, using settings 'djangotut.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Cloud9 Your application is running at https://djangotut-c9-diaz994.c9.io
Cloud9 Error: you may be using the wrong PORT & HOST for your server app
use './manage.py runserver $IP:$PORT' to run your Django application
**Error: You don't have permission to access that port.**
I do not know why it is not allowing me to run this. It seems like it starts the server and then it kills it. Have any of you had experience with this on the c9.io site? Thanks alot.
They don't allow access to the standard ports that django wants to use, but they do provide the appropriate ports in the form of environment variables. Use this instead:
python manage.py runserver $IP:$PORT
That should work.
Yes, thats right. First use
python manage.py runserver $IP:$PORT
to start the development server and than don't forget to add allowed hosts to your settings.py
ALLOWED_HOSTS = ['<your_project_name>.c9users.io']

python manage.py runserver not work

I am trying to learn django on my mac by following along with Writing your first Django app
I run
django-admin.py startproject mysite
and it creates the files it should. Then I try to start the server by running
python manage.py runserver 8080
It's OK,the message is :
Validating models...
0 errors found Django version 1.4.2, using settings 'mysite.settings'
Development server is running at http:// 127.0.0.1:8080/ Quit the
server with CONTROL-C.
But I when I visit the 127.0.0.1:8080, I get a 504 error page:
This Page Cannot Be Displayed
The system cannot communicate with the external server ( 127.0.0.1 ).
The Internet server may be busy, may be permanently down, or may be
unreachable because of network problems. ......
What am I missing here?
Considering you are using a proxy (as mentioned in the comments). The reason for this error:
This Page Cannot Be Displayed
The system cannot communicate with the external server ( 127.0.0.1 ). The Internet server may be busy, may be permanently down, or may be unreachable because of network problems. ......
is that 127.0.0.1 is looked up at the proxy and on the proxy server there is nothing listening on port 8080
Use 'python manage.py runserver 8000' instead of 'python manage.py runserver 8080'
Worked for me.

Categories