curl (56) Recv failure

余生长醉 提交于 2019-12-10 14:55:16

问题


While running the command:

curl --head http://www.yourdomain.com/

on my local machine, I get this output:

HTTP/1.1 200 OK
Date: Sat, 31 Mar 2012 09:45:16 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: ASP.NET_SessionId=p2mt4l553bti4x55geyiwiil; path=/; HttpOnly
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 14663

but on my live server, I just get:

curl: (56) Recv failure: Connection reset by peer

They are both using the same curl version (7.21.0) and for now, I am only getting this error for only one specific url.

How should I fix this?


回答1:


"Recv failure" means a recv() call failed within libcurl, which then indicates a network problem of some sorts. It is hard to be very specific on what you should do to track this down but wiresharking the network to see exactly what happens on TCP level would be a good start.




回答2:


copied from CURL ERROR: Recv failure: Connection reset by peer - PHP Curl

I think the section D,E might help:

D. Maximum Transmission Unit

One common cause of this error is that the MTU (Maximum Transmission Unit) size of packets travelling over your network connection have been changed from the default of 1500 bytes. If you have configured VPN this most likely must changed during configuration

D. Firewall : iptables

If you don't know your way around this guys they would cause some serious issues .. try and access the server you are connecting to check the following

You have access to port 80 on that server Example

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT` The Following is at the last line not before any other ACCEPT Example

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited Check for ALL DROP , REJECT and make sure they are not blocking your connection

Temporary allow all connection as see if it foes through



来源:https://stackoverflow.com/questions/9954877/curl-56-recv-failure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!