本地 WordPress 站点 returns 上的 cURL:错误 6(无法解析主机)
cURL on local WordPress site returns: Error 6 (Could not resolve host)
我有一个本地 WordPress 安装 运行ning 在:https://catalogue3.test.
请注意,所有 .test
域都应解析为 localhost
,因为我使用 Laravel valet。但是,当我在我的 Laravel 项目中执行以下代码时,出现如下所示的异常。
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', "https://catalogue3.test", ['verify' => false]);
ConnectException
cURL error 6: Could not resolve: catalogue3.test (Domain name not
found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
当我 运行 在终端中执行以下命令时,会显示 WordPress 页面。
curl https://catalogue3.test/ --insecure
我通过将 catalogue3.test 添加到 /etc/hosts
解决了这个问题,即使我使用的是 DnsMasq
,理论上我也不需要它。
添加
ip catalogue3.test
到您的 /etc/hosts 文件
在我的例子中(在 macOS 上)我必须在我的 WiFi 设置中添加 127.0.0.1 作为第一个 DNS 服务器选项。
这里还有一些有用的信息:https://github.com/laravel/valet/issues/736
我尝试将域添加到主机并尝试更改网络设置中的 dns,this answer 对我有用。
Quick way to check if this is your problem is to do: curl --version
and php --ri curl
The versions should match. If they don't it's probably because brew
has installed curl-openssl. This can be removed by doing:
brew uninstall curl-openssl --ignore-dependencies
Maybe there's a way to configure the installed curl-openssl properly -
I've not investigated this yet.
我有一个本地 WordPress 安装 运行ning 在:https://catalogue3.test.
请注意,所有 .test
域都应解析为 localhost
,因为我使用 Laravel valet。但是,当我在我的 Laravel 项目中执行以下代码时,出现如下所示的异常。
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', "https://catalogue3.test", ['verify' => false]);
ConnectException
cURL error 6: Could not resolve: catalogue3.test (Domain name not found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
当我 运行 在终端中执行以下命令时,会显示 WordPress 页面。
curl https://catalogue3.test/ --insecure
我通过将 catalogue3.test 添加到 /etc/hosts
解决了这个问题,即使我使用的是 DnsMasq
,理论上我也不需要它。
添加
ip catalogue3.test
到您的 /etc/hosts 文件
在我的例子中(在 macOS 上)我必须在我的 WiFi 设置中添加 127.0.0.1 作为第一个 DNS 服务器选项。
这里还有一些有用的信息:https://github.com/laravel/valet/issues/736
我尝试将域添加到主机并尝试更改网络设置中的 dns,this answer 对我有用。
Quick way to check if this is your problem is to do:
curl --version
andphp --ri curl
The versions should match. If they don't it's probably because brew has installed curl-openssl. This can be removed by doing:
brew uninstall curl-openssl --ignore-dependencies
Maybe there's a way to configure the installed curl-openssl properly - I've not investigated this yet.