What is the curl error 52 “empty reply from server”?

前端 未结 15 2647
忘了有多久
忘了有多久 2020-11-29 02:22

I have a cron job setup on one server to run a backup script in PHP that is hosted on another server.

The command I\'ve been using is

curl -sS http://w         


        
相关标签:
15条回答
  • 2020-11-29 02:57

    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
    
    0 讨论(0)
  • 2020-11-29 02:57

    My case was due to SSL certificate expiration

    0 讨论(0)
  • 2020-11-29 02:58

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

    0 讨论(0)
  • 2020-11-29 02:59

    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.

    0 讨论(0)
  • 2020-11-29 03:00

    Try this -> Instead of going through cURL, try pinging the site you’re trying to reach with Telnet. The response that your connection attempt returns will be exactly what cURL sees when it tries to connect (but which it unhelpfully obfuscates from you). Now, depending on what what you see here, you might draw one of several conclusions:

    You’re attempting to connect to a website that’s a name-based virtual host, meaning it cannot be reached via IP address. Something’s gone wrong with the hostname—you may have mistyped something. Note that using GET instead of POST for parameters will give you a more concrete answer.

    The issue may also be tied to the 100-continue header. Try running curl_getinfo($ch, CURLINFO_HTTP_CODE), and check the result.

    0 讨论(0)
  • 2020-11-29 03:01

    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.

    0 讨论(0)
提交回复
热议问题