2017-01-01 20:02

file_get_contents无效 - 连接被拒绝


After reading the following links:

I'm having a problem with the function file_get_contents or even curl in one of my servers at hostgator, they are not working, returning the PHP error failed to open stream: Connection refused. I've tried cURL with USERAGENT set with no result too. It's a simple weather service that I'm creating, it returns the altitude, wind direction, speed and temperature on a certain coordinate of the globe.

Return sample: 30000;221;2;-32;1;

In the other side (request side), I have a web server running IIS 7.5, with all router firewalls, computers firewalls and antivirus softwares disabled only for testing, and is still refusing the connection ONLY for the hostgator servers. I've tried the same code in other web hosting providers, and the code is working properly.

This service will handle a lot of requests per minute, and this seems to me that something has blocked my connection between hostgator and my server due to the number of requests. But I don't know where!!

The page is perfectly accesible via browser.

This is my enviorioment at the hostgator side:

  • allow_url_fopen: On
  • allow_url_include: On
  • OpenSSL: Enabled

Here is my PHP code:

$datalink = "http://#####.########.###:8280/weather.php?waypoint_lat=-10.981925&waypoint_lon=-37.077377&altitude=30000";

$weather_layer = file_get_contents($datalink);

echo "Layer ($datalink):" .$weather_layer."<br>";
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dou91808 dou91808 4年前

    Isn't Hostgator blocking the requests because of the DDoS protection? Give them a call, my hosting provider was blocking connections to my other server because they were thinking it was some hacker DDoSing using my hosting.

    Also, there might be problem with the port in URL - Hostgator cannot proccess it?

    点赞 评论 复制链接分享