Composer报错getaddrinfo failed: Name or service not known的解决办法。
详细错误:
[Composer\Downloader\TransportException]
The "https://repo.packagist.org/p/simple-swoole/skeleton.json" file could not be downloaded: php_network_getaddresses: getaddrinfo failed: Name or service not known
failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known
分析原因:
服务器DNS解析有误,用ping命令测试百度等网页,提示Name或Server not known。
解决办法:
设置服务器DNS地址为其他公共DNS,如:114.114.114.114
Linux系统的文件路径一般为/etc/resolv.conf,如果是宝塔面板也可以用Linux工具箱进行设置。
完成DNS设置后composer的错误就解决了。