python manage.py runserver is not working - python

So before anyone point it out, my question is really similar to this question but the error message is slightly different.
So I just started learning Django this day and I got stuck because when I ran python manage.py runserver it didn't display anything until I hit "CTRL + C" then this message showed up
Performing system checks...
System check identified no issues (0 silenced).
July 30, 2020 - 15:51:40
Django version 2.1.5, using settings 'trydjangofcc.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
(mine)
I tried to go to the http://127.0.0.1:8000/ and it didn't work, I've tried python manage.py migrate still nothing.
I've waited an hour to see if it makes a difference and it doesn't. It seems stupid but I've been stuck here for a while.

You could try entering this into your URL bar :
http://localhost:8000/

try these steps:
run application with different port number, for example use 9000 as your port number, try this: python manage.py runserver 127.0.0.1:9000
check your hosts file (in windows 10: C:\WINDOWS\System32\drivers\etc\hosts or in centos: /etc/hosts ) and search for 127.0.0.1, it may redirect "127.0.0.1" to defferent url not localhost

the message you got isn't an error, that exactly what manage.py runserver does..
Just click on the link. It will open the server.
Oh, and CTRL+C mean CANCEL an action

Make sure after running the server you DO NOT USE crl+C, as it is canceling the server.
for copying the URL use right click and copy.

Related

Django refuses to connect

I created my Django website, whenever I try to go on the website, it says 127.0.0.1 is not responding. I tried troubleshooting it and it says 127.0.0.1 is refusing connection. everywhere it says that there's a firewall issue how do I fix
Just to be sure because you didn't mention it, did you launch the server with the following command?
python manage.py runserver
use this command in cmd:
python manage.py runserver
after that, you will see the IP and the port as shown in the image below
http://127.0.0.1:8000

why is django server not working? (connection refused error)

I am doing a course : cs50 web programming with python and in project 2 Commerce while using
python manage.py runserver I am getting this error:
This site can’t be reached
127.0.0.1 refused to connect.
this is project 2 commerce. https://cs50.harvard.edu/web/2020/projects/2/commerce/
I have not made any changes to the distribution code
for my last project I was able to make it work by using this code in settings.py :
ALLOWED_HOSTS = ["ide-2f9427eaa96d41debb489eacf31c97d6-8080.cs50.ws"]
and changing url to the same
but on using it in this project I get this error:
403 Forbidden
edit
this is the solution I found from the comments:
As suggested in the comments I changed ALLOWED_HOSTS = [*] in settings.py of my django file.
then in the terminal I tried running the command python manage.py runserver 0.0.0.0:8080
On clicking the link I got a URL like this:
{ide URL}:8080
and this error:
This site can’t be reached
next I changed the URL manually to {IDE URL}-8080.cs50.wswhich is the URL for the web server in the IDE I am using.
this seemed to work for me.
The problem may have been because port 8000 is being used by another service and earlier I was not able to use port 8080 because I was using the wrong URL for my IDE's web server.
check settings.py and make sure debug is set to True. Then go to allowed hosts and set it to ['*'].
This will allow anyone on your system to connect to localhost server
By default the server runs on port 8000 so you might want to try 127.0.0.1:8000 in your URL

My system is not connecting to development server 127.0.0.1:8000 for a django project

I am using Windows 8.1. When I run a command to start the django server using
python manage.py runserver
it runs fine. But when I open 127.0.0.1:8000 in the browser it says:
This site can't be reached.
127.0.0.1 took too long to respond.
I have already tried to change the port number by using
python manage.py runserver 8080
but still it doesn't run.
Please help me solving this issue.

Error 404 when trying to access a Django app installed in a subdomain

I just installed Django and create a project and an app following the basic tutorial part 1, I created a virtualenv since centOS default python version is 2.4.3, I also created a subdomain to work on this for the development phase. when I try to access like dev.domain.com/admin/ or dev.domain.com/ I get a 404 error, it's like django is not even there. When I run the server I get a normal response:
(python2.7env)-bash-3.2# python manage.py runserver
Validating models...
0 errors found
February 22, 2014 - 23:54:07
Django version 1.6.2, using settings 'ct_project.settings'
Starting development server at http://127.0.0.1:8000/
Any ideas what I'm missing?
EDIT:after starting the server correctly(with the right ip) I tried again and as a result I got the browser hanging. Then I went to tried an online port scanner and found out that the port 8000 is not responding, any ideas what I can try next?
Thanks
You need to have you hosts entry on /etc/hosts like the following one
127.0.0.1 dev.domain.org
By default Django start the dev web server on port 8000 and you browser is looking for the server on port 80 (default port for webservers) so you need to add the port at the end of the url
http://dev.domain.com:8000.
if you want to start the server in default port 80 you need to specify it (migth need root or sudo):
python manage.py runserver http://dev.domain.com:80
The issue was solved by contacting the support service and asking them to open the port 8000 for me.

Python 2.6.2, Django 1.0.3, Windows XP, Page not found: /

I'm just starting to learn Python and Django and an unable to get the most basic app working. I've setup Python, added python to the Path environment variable, installed Django using install.py script.
I created an app by running the command
django-admin.py startproject my_project
updated the settings.py file for a database
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'mysitedb'
Ran the command
python manage.py syncdb
And finally, started everything up
python manage.py runserver
To this point, everything looks to have run successfully. When I got to view http://localhost:8000/ I get the error "Page not found: /"
I originally installed Django version 1.1, but got the same error, so I removed it and tried the older version 1.0.3. Niether work. Any help would be appreciated.
To complete this question - #artran's answer of changing the port
python manage.py runserver 8001
will work.
When python runs the server, it automatically uses port 8000 (hence http://127.0.0.1:8000/). It uses this port as to not tread on the toes of other applications using localhost ports. However, you may still have an application or service running through this port. As such using port 8001 or any other port you may consider free should work.
To repair this in the future, you need to run a program of which can finger all your ports and determine what application is using the :8000 port.
It sounds like you need to create some apps for your project and set up the urls. As you are just starting you'd be best following the tutorial right through to get a feel for it all.
You probably have ADMIN_MEDIA_PREFIX = "" in your settings. Django intercepts requests to this url and attempts to serve admin media, thus when you make it an empty string, it will attempt to intercept ALL requests, resulting in nothing working.

Categories

Resources