![](/img/trans.png)
[英]Laravel guzzle cURL error 6: Could not resolve host: http (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
[英]cURL error 6: Could not resolve host: test.example.localhost (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in
我試圖卷曲到我的本地主機 laravel 站點。 我正在使用 XAMPP 7.1 當我嘗試重新連接此代碼時,總是會出現錯誤(而不是200 OK
響應)
致命錯誤:未捕獲的 GuzzleHttp\\Exception\\ConnectException:cURL 錯誤 6:無法解析主機:test.example.localhost(參見http://curl.haxx.se/libcurl/c/libcurl-errors.html )在 D:\\ xamp7.1\\htdocs\\wittymanager\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php:185 堆棧跟蹤:#0 D:\\xamp7.1\\htdocs\\wittymanager\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory .php(149): GuzzleHttp\\Handler\\CurlFactory::createRejection(Object(GuzzleHttp\\Handler\\EasyHandle), Array) #1 D:\\xamp7.1\\htdocs\\wittymanager\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory .php(102): GuzzleHttp\\Handler\\CurlFactory::finishError(Object(GuzzleHttp\\Handler\\CurlHandler), Object(GuzzleHttp\\Handler\\EasyHandle), Object(GuzzleHttp\\Handler\\CurlFactory)) #2 D:\\xamp7.1 \\htdocs\\wittymanager\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlHandler.php(43): GuzzleHttp\\Handler\\CurlFactory::finish(Object(GuzzleHttp\\Handler\\CurlHandler), Object(GuzzleHttp\\Handler\\EasyHandle), Object (GuzzleHttp\\Handler\\CurlFactory)) #3 D:\\xamp7.1\\htdocs\\wit tymanager\\vendor\\guzzlehttp\\guzzle in D:\\xamp7.1\\htdocs\\wittymanager\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php on line 185
// URL = http://test.example.localhost/api/lang-sync
public static function test($url, $data) {
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', $url, $data);
$response = $res->getBody();
if($res->getStatusCode() == 200)
{
print_r($res);
} else {
print_r($response);
}
}
在登台服務器上沒問題。 重新啟動 xampp 沒有幫助。
編輯:
test.example.localhost 已添加到主機文件中。
這是一個向 Laravel API 發送 http 請求的 wordpress 插件。
這個應用實際上是在使用https://github.com/hyn/multi-tenant 。 用於多站點集成
它寫道:
無法解析主機:
test.example.localhost
打開C:\\Windows\\System32\\Drivers\\etc\\hosts
並添加以下條目:
127.0.0.1 test.example.localhost
以便知道主機名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.