dongya3627 2019-08-13 02:14
浏览 227
已采纳

AWS Amazon Server:cURL错误无法解析主机

I've been using a fanless ubuntu server for a couple of months and been transferred my Laravel API Passport to different servers like Ubuntu and for development Windows.

The current version of my api is working fine on these servers. Not until when I transferred the laravel project to my AWS Amazon server and getting the error like this

{
"message": "cURL error 6: Could not resolve host: api-a.mydomain.comoauth (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)",
"exception": "GuzzleHttp\\Exception\\ConnectException",
"file": "/var/www/html/api_tk_a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php",
"line": 185,
"trace": [
{
   ....some line of multiple errors
}
]

}

I tried to add some line of code to my etc/hosts file

like this

52.***.***.205 api-a.mydomain.com 52.***.***.205 api-b.mydomain.com

or

127.0.0.1 api-a.mydomain.com 127.0.0.1 api-b.mydomain.com

tried also my inet addr:171.*.**.** to put on my hosts file still getting the same error

I have 2 different api that's why there's a and b

But nothing of these works.

Can anyone point out the reason why I'm getting this error.

Some thread says this has nothing to do with the Guzzle but clearly states to the IP and DNS. But I can't find a good way to figure this out.

UPDATE

My .env file has something like this

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:1AEVUl5JHMzLkhxU7MDlDHtfZ6KB9UybjzUxLaYp9vg=
APP_DEBUG=true
APP_URL=http://localhost

I tried to put the APP_URL as https://api-a.mydomain.com still not working..

API CODE This code is working fine

$http = new Client;
        $response = $http->post(url('oauth/token'), [
            'form_params' => [
            'grant_type' => 'password',
            'client_id' => '2',
            'client_secret' => '8mEsN0RZkljKZlbiJFfnNKahcbcOVkoQVG7C2Xwl',
            'username' => $user->email,
            'password' => $request->password,
            'scope' => '',
            ],
        ]);

This is my routes/api.php

use Illuminate\Http\Request;
Route::post('/login','Auth\Api\AuthController@login');

EC2 Ping

enter image description here

  • 写回答

2条回答 默认 最新

  • doushun1904 2019-08-15 03:00
    关注

    I found a solution:

    I used $http->post('https://api-a.mydomain.com' . '/oauth/token', [

    Laravel passport trying to get oauth/token. Guzzle keeps hanging, also on other Guzzle calls

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 专家修改了标签 8月30日

悬赏问题

  • ¥30 征集Python提取PDF文字属性的代码
  • ¥15 如何联系真正的开发者而非公司
  • ¥15 有偿求苍穹外卖环境配置
  • ¥15 代码在keil5里变成了这样怎么办啊,文件图像也变了,
  • ¥20 Ue4.26打包win64bit报错,如何解决?(语言-c++)
  • ¥15 clousx6整点报时指令怎么写
  • ¥30 远程帮我安装软件及库文件
  • ¥15 关于#自动化#的问题:如何通过电脑控制多相机同步拍照或摄影(相机或者摄影模组数量大于60),并将所有采集的照片或视频以一定编码规则存放至规定电脑文件夹内
  • ¥20 (求远程解决)深信服vpn-2050这台设备如何配置才能成功联网?
  • ¥15 Arduino的wifi连接,如何关闭低功耗模式?