Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the curl error 52 "empty reply from server"?

Tags:

curl

cron

People also ask

What causes Empty reply from server?

The "empty reply from server" error indicates that a zero length response was received - no HTTP headers or content, simply a closed TCP connection with no HTTP payload transmitted. One common cause of this problem is attempting to make a plain HTTP request against the HTTPS (TLS / SSL) web server port.

What is a cURL error?

cURL errors are often caused by an outdated version of PHP or cURL. cURL errors are a good example of server-related errors. These are errors that aren't caused by WordPress or Really Simple SSL, but by a server configuration. These errors usually won't cause any issues on the front end of your site.


This can happen if curl is asked to do plain HTTP on a server that does HTTPS.

Example:

$ curl http://google.com:443
curl: (52) Empty reply from server

Curl gives this error when there is no reply from a server, since it is an error for HTTP not to respond anything to a request.

I suspect the problem you have is that there is some piece of network infrastructure, like a firewall or a proxy, between you and the host in question. Getting this to work, therefore, will require you to discuss the issue with the people responsible for that hardware.


It can happen when server does not respond due to 100% CPU or Memory utilization.

I got this error when I was trying to access sonarqube API and the server was not responding due to full memory utilization


In my case it was server redirection; curl -L solved my problem.


Another common reason for an empty reply is timeout. Check all the hops from where the cron job is running from to your PHP/target server. There's probably a device/server/nginx/LB/proxy somewhere along the line that terminates the request earlier than you expected, resulting in an empty response.


In case of SSL connections this may be caused by issue in older versions of nginx server that segfault during curl and Safari requests. This bug was fixed around version 1.10 of nginx but there is still a lot of older versions of nginx on the internet.

For nginx admins: adding ssl_session_cache shared:SSL:1m; to http block should solve the problem.

I'm aware that OP was asking for non-SSL case but since this is the top page in goole for "empty reply from server" issue, I'm leaving the SSL answer here as I was one of many that was banging my head against the wall with this issue.


In my case this was caused by a PHP APC problem. First place to look would be the Apache error logs (if you are using Apache).

Hope this helps somebody.