本地WordPress站点上的cURL返回:错误6(无法解析主机)

问题描述 投票:1回答:3

我有一个运行在:https://catalogue3.test的本地WordPress安装。

请注意,所有.test域应解析为localhost,因为我使用Laravel valet。但是,当我在Laravel项目中执行以下代码时,我得到一个例外,如下所示。

$client = new \GuzzleHttp\Client();
$response = $client->request('GET', "https://catalogue3.test", ['verify' => false]);

的ConnectException

cURL错误6:无法解析:catalogue3.test(未找到域名)(请参阅http://curl.haxx.se/libcurl/c/libcurl-errors.html

当我在终端中运行以下命令时,将显示WordPress页面。

curl https://catalogue3.test/ --insecure
php wordpress laravel curl guzzle
3个回答
2
投票

ip catalogue3.test

到你的/ etc / hosts文件


2
投票

我解决了这个添加catalogue3.test到/etc/hosts,即使我使用DnsMasq,理论上,我不需要它。


1
投票

在我的情况下(在macos上)我不得不在我的WiFi设置中添加127.0.0.1作为第一个DNS服务器选项。

这里也有一些有用的信息:https://github.com/laravel/valet/issues/736


0
投票

我试图将域添加到主机,我试图在网络设置中更改DNS,this answer对我有用。

快速检查这是否是您的问题的方法是:curl --versionphp --ri curl

版本应该匹配。如果他们不这样做可能是因为brew安装了curl-openssl。这可以通过以下方式删除:

brew uninstall curl-openssl --ignore-dependencies

也许有一种方法可以正确配置已安装的curl-openssl - 我还没有调查过这个。

© www.soinside.com 2019 - 2024. All rights reserved.