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

Solution 1:

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: */*

Solution 2:

Curl is fine, but doesnt give much feedback when things go wrong. (As you can tell) wget may give you more information, but as yoonix mentions, Server side (ie webserver error logs) is the place to look.

wget -S -O /dev/null http://www.example.com

You can set hostnames as well with

wget -s -O /dev/null --header="Host: foo.bar" http://www.example.com

Tags:

Curl

Tcp