predator
predator

Reputation: 477

Django runserver does not respond when opened in the browser

I have been using django for quite some time now and I had no problems in using it, until now.

When I run in the terminal py manage.py runserver 127.0.0.1:8000 it shows

Performing system checks...

System check identified no issues (0 silenced). July 23, 2015 - 16:17:23 Django version 1.8.3, using settings 'projectname.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. Performing system checks...

And then when I opened it in my browser, it does not show me anything. It just load and load and load..

I tried googling it but some suggested that I change my port, so I changed it, some said to use my ipaddress with a port other than 8000, and I did but nothing was of help to me. It's stuck on loading the page.

I am using django 1.8.3. Running it on Windows btw

Upvotes: 14

Views: 19608

Answers (7)

Nassim
Nassim

Reputation: 447

This happens If you use Redis as a cache by default, it will never be opened if you don't start the Redis server, this happens only if you use the Redis cache as follows:

CACHES = {
"default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": os.getenv(
            "REDIS_CACHE_URL", "redis://127.0.0.1:6379/1"
        ),
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        },
    },
}

Upvotes: 0

Zebin Wen
Zebin Wen

Reputation: 1

I solve this problem by change my current node into management node, instead of compute node. Although I don't know why this works, I know when we runserver in compute node, it won't work.

Upvotes: 0

Parishilan Rayamajhi
Parishilan Rayamajhi

Reputation: 3049

try following the following steps:

first find the process running on port 8000 by command:

netstat -tulpn | grep 8000

take the pid and kill it using command

kill pid

run python server using command

 python manage.py runserver 0.0.0.0:8000

Upvotes: 1

Wargream
Wargream

Reputation: 181

Try restarting your computer.

Same thing happened to me on my Windows 10 machine while debugging multiple APIs running locally on flask dev server and accessing them with my Django webapp. Closing and restarting the Django server didn't help as it showed no errors on the console while the webapp page still won't load. Doing a restart eliminates this problem that may have been caused by multiple servers running and restarting while in the process of debugging.

Note: Make sure to do a restart and not a regular shutdown since fast boot is enabled by default as of Windows 8. Else, it will just load the previous state of your system and the problem will persist.

Upvotes: 3

shethedba
shethedba

Reputation: 1

If it helps with anyone. I came across with this problem also running on Windows, restarting Django didn't seem to help. However, when I looked at Task Manager, there seem to be other old python process running. After I killed those process, and restarted Django, it starts working.

Upvotes: 0

FlipperPA
FlipperPA

Reputation: 14311

Give it a try with binding to all of the network interfaces:

python manage.py runserver [::]:8000

You should be able to see what port it is listening on. Go to START, and type cmd. Right click cmd and Run As Administrator. Then type:

netstat

Do you see anything in that list like?

TCP    0.0.0.0:8000          YourPC-PC:0          LISTENING

That would be the listing of the Django runserver in your network ports list.

Upvotes: 4

itzMEonTV
itzMEonTV

Reputation: 20339

Try this with 0.0.0.0 if you are running in remote server.

python manage.py runserver 0.0.0.0:8000

If not, check whether port is listening.

sudo nmap -sT -O localhost #to install=> sudo apt-get install nmap

For windows

>netstat -a -b

Upvotes: 0

Related Questions