PHP: file_get_contents failed to open stream: Connection refused

人盡茶涼 提交于 2019-12-02 05:34:38

问题


I am trying to access a second server with file_get_contents and simple_load_xml and I get "failed to open stream: Connection refused"
What can be the result?

allow_url_fopen=Yes
allow_url_include=Off

is my php.ini values


回答1:


Sounds like the 2nd server is rejecting the file, try using curl to obtain the file instead; the benefit of using curl is that it'll give you helpful debugging information in the event of a failure like this. get_file_content() masks a lot of this helpful information.




回答2:


Your connection to the resource is being rejected. Ensure that you can access the resource from the server (Using Lynx for instance).




回答3:


I believe this is because you need a resource - fopen(), instead of a string - file_get_contents()



来源:https://stackoverflow.com/questions/3098129/php-file-get-contents-failed-to-open-stream-connection-refused

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