How to troubleshoot connectivity when curl gets an *empty response*

curltcp

I want to know how to proceed in troubleshooting why a curl request to a webserver doesn't work. I'm not looking for help that would be dependent upon my environment, I just want to know how to collect information about exactly what part of the communication is failing, port numbers, etc.

chad-integration:~ # curl -v 111.222.159.30
* About to connect() to 111.222.159.30 port 80 (#0)
*   Trying 111.222.159.30... connected
* Connected to 111.222.159.30 (111.222.159.30) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.0 (x86_64-suse-linux-gnu) libcurl/7.19.0     OpenSSL/0.9.8h zlib/1.2.3 libidn/1.10
> Host: 111.222.159.30
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host 111.222.159.30 left intact
curl: (52) Empty reply from server
* Closing connection #0

So, I understand that an empty response means that curl didn't get any response from the server. No problem, that's precisely what I'm trying to figure out.

But what more specific info can I derive from cURL here?

It was able to successfully "connect", so doesn't that involve some bidirectional communication? If so, then why does the response not come also? Note, I've verified my service is up and returning responses.

Note, I'm a bit green at this level of networking, so feel free to provide some general orientation material.

Best Answer

You likely will need to troubleshoot this from the server side, not the client side. I believe you are confusing an 'empty response' with 'no response'. They do not mean the same thing. Likely you are getting a reply that does not contain any data.

You can test this by simply using telnet instead of going through curl:

telnet 111.222.159.30 80

Once connected, paste the following (taken from your curl output):

GET / HTTP/1.1
User-Agent: curl/7.19.0 (x86_64-suse-linux-gnu) libcurl/7.19.0     OpenSSL/0.9.8h zlib/1.2.3 libidn/1.10
Host: 111.222.159.30
Accept: */*

You should see the response exactly as curl sees it.

One possible reason you are getting an empty reply is that you're trying to hit a website that is a name-based virtual host. If that's the case, depending on server configuration (the site you're trying to hit happens to be configured as the default) you cannot reach the site by IP address without a little bit of work.

You can test that on the client side by simply changing the 'Host' line above; replace www.example.com with the site you're trying to reach:

GET / HTTP/1.1
User-Agent: curl/7.19.0 (x86_64-suse-linux-gnu) libcurl/7.19.0     OpenSSL/0.9.8h zlib/1.2.3 libidn/1.10
Host: www.example.com
Accept: */*
Related Topic