在使用 file_get_contents远程请求url时,出现警告:
php_network_getaddresses: getaddrinfo failed: Name or servicenot known
这个问题通常是由于 Apache/PHP主机连不上dns服务器。

首先,要在命令行下检查,是否能ping通远程主机。

如果ping不通,那么你的name server(如果是fedora,在/etc/resolv.conf文件中)设置有问题。找一个可以使用的dns,用该dns的ip替换/etc/resolv.conf 中第一个nameserver的ip,然后重启apache。
如果能ping通,那么apache现在连的是一个有问题的dns服务器。你需要重启apache,以便从/etc/resolv.conf中刷新dns服务器列表。
如果还不行,可以尝试在apaceh的 http.conf 里面设上
 
ServerName=localhost
或者
ServerName=127.0.0.1
这个方法也用于解决apache启动时出现apr_sockaddr_info_get() failed的错误

如果还是不能解决,可以试试如下建议:
1)检查要请求的远程主机是不是在本机的/etc/hosts中
2)检查防火墙的规则,是不是被拦截了‘
3)在/etc/hosts手动绑定host

原文:https://blog.csdn.net/ownfire/article/details/7850890

php_network_getaddresses: getaddrinfo failed的更多相关文章

  1. php提示php_network_getaddresses: getaddrinfo failed: Name or service not known

    php_network_getaddresses: getaddrinfo failed: Name or service not known 面对这个错误,已经相对熟悉了.想起来应该是服务器无法访问 ...

  2. php_network_getaddresses: getaddrinfo failed 原因

    一般在调用外部服务请求时候,有时由于配置问题无法访问,phph会报一个php_network_getaddresses: getaddrinfo failed: Name or servicenot ...

  3. 阿里云SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

    如果是阿里云的服务器 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in ...

  4. dns未设置 PHP Warning: file_get_contents():php_network_getaddresses: getaddrinfo failed:

    php通过去访问外部网站时,出现以下提示: PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed ...

  5. file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known

    请求页面时候报错 file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not know ...

  6. [PDOException] PDO::__construct(): php_network_getaddresses: getaddrinfo failed:

    执行数据迁移 php artisan migrate 报错: 网上很多资料说开启allow_open_url等其实没卵用...貌似问题出在dns上....原来数据库的配置是这样的 DB_CONNECT ...

  7. libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)

    log报错如下: Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated w ...

  8. 记踩坑--Flask Web开发:S6电子邮件 ----[Errno 11004] getaddrinfo failed

    必须要记录下踩过的坑,一来,为后来者铺路,二来,实在摔得疼,提醒自己写代码要谨小慎微. [Errno 11004] getaddrinfo failed 1.先排除邮箱账号和授权码的错误 测试如下代码 ...

  9. #python# error:urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>

    设置代理后访问网页报错,百度有人说地址拼写不对,确认拼写后依然报错 因为使用的是xici免费代理,想到可能代理不可用造成getaddrinfo failed, 更换其他代理,error消失

随机推荐

  1. springboot日志框架学习------slf4j和log4j2

    springboot日志框架学习------slf4j和log4j2 日志框架的作用,日志框架就是用来记录系统的一些行为的,可以通过日志发现一些问题,在出现问题之后日志是好的一个帮手. 市面上的日志框 ...

  2. hiper、sitespeed性能工具

    https://github.com/pod4g/hiper   hiper:   A statistical analysis tool for performance testing https: ...

  3. 转载: Ubuntu 在命令下,安装中文环境的方法。

    转载: https://blog.csdn.net/zhangchao19890805/article/details/52743380 安装英文版ubuntu,在打开含有中文字符文件时会乱码,有需要 ...

  4. Linux 的帐号与群组:有效与初始群组、groups, newgrp

    关于群组: 有效与初始群组.groups, newgrp 认识了帐号相关的两个档案 /etc/passwd 与 /etc/shadow 之后,您或许还是会觉得奇怪, 那么群组的设定档在哪里?还有,在 ...

  5. laravel-admin 添加图表 Chartjs

    github地址:https://github.com/laravel-admin-extensions/chartjs Installation composer require laravel-a ...

  6. 【LOJ 6695】天气之子

    找规律题的典范? OEIS裸题 考场上让你用 OEIS 吗 题意 link 题解 \(n\le 5\) 打表 \(n\le 10^5\) 发现不能直接求最优解,于是二分答案. 验证答案时,先把前 \( ...

  7. Acwing-278-数字组合(背包)

    链接: https://www.acwing.com/problem/content/280/ 题意: 给定N个正整数A1,A2,-,AN,从中选出若干个数,使它们的和为M,求有多少种选择方案. 思路 ...

  8. 在angular中使用ng-repeat时数组中有重复元素,要用item in items track by $index

    在angular中使用ng-repeat时数组中有重复元素,要用item in items track by $index,不然会报错 <div class="" ng-in ...

  9. jquery target属性 语法

    jquery target属性 语法 作用:target 属性规定哪个 DOM 元素触发了该事件.大理石平台精度等级 语法:event.targe 参数: 参数 描述 event     必需.规定需 ...

  10. JAVA大文件上传断点续传解决方案

    javaweb上传文件 上传文件的jsp中的部分 上传文件同样可以使用form表单向后端发请求,也可以使用 ajax向后端发请求 1.通过form表单向后端发送请求 <form id=" ...