Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

matttonks11's avatar

Curl Error 6 on production server

Hi there,

I'm having issues with my web applications deployed via forge on a VPS i have set up.

I will randomly get a curl error 6 - could not resolve host when doing things like trying to log users in via a Socialite package. At first I thought it was an issue with the code but I set the same project up on a Digital Ocean droplet and there aren't any issues.

Does anybody know of any issues, more importantly any checks or fixes I could be doing?

Any help would be majorly appreciated

0 likes
7 replies
matttonks11's avatar

Hi here's the specific error code and the code used

cURL error 6: Could not resolve host: graph.microsoft.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)


 public function handleOauthResponse()
    {
        $user = Socialite::driver('azure-oauth')->user();

        $authUser = $this->findOrCreateUser($user);

        auth()->login($authUser, true);

        return redirect(
            config('azure-oath.redirect_on_login')
        );
    }

I looked through the stack trace and this is the code used by the socialite package I installed.

protected function getUserByToken($token)
    {
        $response = $this->getHttpClient()->get('https://graph.microsoft.com/v1.0/me/', [
            'headers' => [
                'Authorization' => 'Bearer '.$token,
            ],
        ]);
 
        return json_decode($response->getBody(), true);
    }

What's weird is it works sometimes on the production server, but works every time on the digital ocean droplet I set up

stefanbauer's avatar

I think it's not a Laravel related problem. Your code seems right. Does DNS resolution work fine? Seems your resolution has a problem. What das nslookup, dig and ping say?

matttonks11's avatar

@stefanbauer Here's the output from nslookup & dig

nslookup graph.microsoft.com
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
graph.microsoft.com canonical name = prd.ags.msidentity.com.
prd.ags.msidentity.com  canonical name = www.ags-prd.akadns.net.
Name:   www.ags-prd.akadns.net
Address: 20.190.143.50
Name:   www.ags-prd.akadns.net
Address: 20.190.143.52
Name:   www.ags-prd.akadns.net
Address: 20.190.143.51
Name:   www.ags-prd.akadns.net
Address: 20.190.143.49
; <<>> DiG 9.11.3-1ubuntu1.9-Ubuntu <<>> graph.microsoft.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28346
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;graph.microsoft.com.       IN  A

;; ANSWER SECTION:
graph.microsoft.com.    3030    IN  CNAME   prd.ags.msidentity.com.
prd.ags.msidentity.com. 175 IN  CNAME   www.ags-prd.akadns.net.
www.ags-prd.akadns.net. 167 IN  A   20.190.143.49
www.ags-prd.akadns.net. 167 IN  A   20.190.143.50
www.ags-prd.akadns.net. 167 IN  A   20.190.143.52
www.ags-prd.akadns.net. 167 IN  A   20.190.143.51

;; Query time: 2 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Wed Sep 11 14:22:09 UTC 2019
;; MSG SIZE  rcvd: 181

matttonks11's avatar

The server itself is an on-premise server and my workplace has a proxy, would this affect it in anyway?

stefanbauer's avatar

This might be a problem. I don't know your infrastructure. But I think it's a network-related problem, which can by anything. Maybe a traceroute will be helpful as well. Then you might see where the packages get lost. But the curl error is more about DNS resolution problem.

Please or to participate in this conversation.