简体   繁体   English

无法打开流:无法分配请求的地址

[英]failed to open stream: Cannot assign requested address

I am using code like this:我正在使用这样的代码:

echo file_get_contents('https://example.com/file.txt');

In response I get an error:作为回应,我收到一个错误:

Warning: file_get_contents( https://example.com/file.txt ): failed to open stream: Cannot assign requested address in /sites/example.com/test.php on line 2警告: file_get_contents( https://example.com/file.txt ):无法打开流:无法在第2行的 /sites/example.com/test.php 中分配请求的地址

As I understand it, the server for some reason forbids accessing the file_get_contents () function if the file is located on the same server.据我了解,如果文件位于同一服务器上,则服务器出于某种原因禁止访问 file_get_contents () 函数。 Because queries like this work:因为这样的查询有效:

echo file_get_contents('https://example.org');

Help me please.请帮帮我。 In which direction to dig?往哪个方向挖?

in /etc/hosts file在 /etc/hosts 文件中

127.0.1.1 example.com example

replaced by取而代之

external_ip of example.com example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoDB错误:无法分配请求的地址 - MongoDB error: Cannot assign requested address 带有NTLM-proxy的Docker中的PHP:无法分配请求的地址 - PHP in Docker with NTLM-proxy: Cannot assign requested address 未捕获 PHP 异常 RedisException:“无法分配请求的地址” - Uncaught PHP Exception RedisException: "Cannot assign requested address" PHP-内存缓存随机失败,-无法分配请求的地址(99) - PHP - memcache randomly fails with - Cannot assign requested address (99) PHP-MySQLi连接随机失败,并显示“无法分配请求的地址” - PHP-MySQLi connection randomly fails with “Cannot assign requested address” 带有 mailcatcher 的 Laravel 抛出异常无法分配请求的地址 - Laravel with mailcatcher thrown exception Cannot assign requested address 无法移动上传的文件无法打开流 - cannot move uploaded files failed to open stream php 无法侦听 172.0.0.1:8080(原因:无法分配请求的地址) - php Failed to listen on 172.0.0.1:8080 (reason: Can't assign requested address) php SoapClient在执行soap请求时出现错误“无法分配请求的地址” - php SoapClient I get an error “Cannot assign requested address” when doing a soap request 无法包含现有文件-无法打开流:权限被拒绝 - cannot includ a existing file - failed to open stream: Permission denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM