Django refuses to connect - python

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

Related

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

python manage.py runserver is not working

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.

Django cannot run server

I just started learning Django
and it's stopping me from the beginning.
as you can see from the image, whenever I try to runserver Errno 11001 comes in.
So I googled it and seemed like proxy problem
so I tried everything I could find but nothing fixed it.
(environmental variables, trying different proxys, etc..)
Can anybody helpme plzzzz
Even though Django's official starter tutorial suggests that we can use '0' as a shortcut for IP '0.0.0.0' the command runserver throws an error Error: [Errno 11001] getaddrinfo failed when the shortcut is used with it.
Use
python manage.py runserver 0.0.0.0:8000
to listen on all available public IPs on port 8000 instead of
python manage.py runserver 0:8000
No, that's now how you should run the server you have to pass ip address and port number like this
python manage.py runserver 0.0.0.0:800
hope this helps!
Run Django server with this command
python manage.py runserver
Or
python manage.py runserver 0.0.0.0:8000
Here, 8000 is port, you can use other port as well.

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.

Running django on 0.0.0.0:8000

I am using vagrant along with Virtualbox, so I can't runserver on the default port and address or it won't work.
Django says:
(...) to listen on all public IPs (useful if you want to show off your work on
other computers), use:
python manage.py runserver 0.0.0.0:8000
Then I tried to access the server via http://127.0.0.1:8888/ but it says Unable to connect. Any guess how to run the server correctly?
I have followed the gettingstartedwithdjango vidoes and this http://127.0.0.1:8888/ worked for the author.
For people who are just looking where to configure the IP, it is run like so (as seen in the OP) -
python manage.py runserver 0.0.0.0:8000
If you are accessing it over your local network you will also need to update settings.py with the IP of your host, as well as specifying localhost. Your local IP can be gotten on Windows by running ipconfig in the command prompt, or ip addr show in the terminal on Ubuntu.
ALLOWED_HOSTS = ['192.168.1.XXX', 'localhost']
You have to run with root privileges. If you run with sudoyou will succeed.
UPDATE 1
The previous information is irrelevant with the topic.
In vagrant you have to forward your port to a local port. Please have a look at this.
UPDATE 2
This page explained how to install and configure django in a vagrant box.

Categories

Resources