cannot curl on localhost, django server

0

I make a draft django website with django-admin startproject mysite

I go into the directory and run the server python manage.py runserver

I check localhost:8000 with my browser and it shows the default welcome page (which means it works). The server logs:

Django version 2.1.5, using settings 'course.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[29/Jan/2019 08:16:54] "GET / HTTP/1.1" 200 16348
[29/Jan/2019 08:16:54] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[29/Jan/2019 08:16:54] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 82564
[29/Jan/2019 08:16:54] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 80304
Not Found: /favicon.ico
[29/Jan/2019 08:16:54] "GET /favicon.ico HTTP/1.1" 404 1972
[29/Jan/2019 08:16:55] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 81348

However, when I try to curl it with curl -v localhost:8000 it hangs forever:

* Rebuilt URL to: localhost:8000/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.58.0
> Accept: */*
> 

Here is the only line that the server logs:

[29/Jan/2019 08:27:53] "GET / HTTP/1.1" 200 16348

On local machine I can check mysite manually but without curl I do not know how to test my site on server. Anyone knows why?

I have tried many suggestion, curl with -4 option, change the port to 8080 for example, change server to 0.0.0.0, use gunicorn to serve.. the problem persists.

Linh Chi Nguyen

Posted 2019-01-29T08:21:35.943

Reputation: 1

Answers

0

I am sorry I am a turbo noob. Here is the answer to my situation:

I run the server with python manage.py runserver and then I Ctrl+z but did not bg to background that process and I thought that it is still running so I curl localhost:8000 but it hangs.

Today, I run the server in a terminal tab and try to curl in another tab, it works. :-p

God forgive me.

Linh Chi Nguyen

Posted 2019-01-29T08:21:35.943

Reputation: 1