next-auth: Request timed out error while using Google provider

Description 🐜

After following the docs for Prisma Adapter and Google Provider, I added auth to my repo, but when trying to log in through google auth, it’s timing out for some reason.

image

I even tried with a longer timeout, but still no luck 😦

providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
      httpOptions: {
        timeout: 10000,
      }
    })
  ],

image

Is this a bug in your own project?

Yes

How to reproduce ☕️

I replicated the issue in a new separate repo, just add the env variable and run it in local - https://github.com/Nikit-Singh/next-auth-google-issue

Screenshots / Logs 📽

No response

Environment 🖥

System: OS: Windows 10 10.0.22000 CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor Memory: 4.38 GB / 15.95 GB Binaries: Node: 16.13.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22000.120.0), Chromium (96.0.1054.62) Internet Explorer: 11.0.22000.120
npmPackages: next: 12.0.10 => 12.0.10 next-auth: ^4.2.1 => 4.2.1 react: 17.0.2 => 17.0.2

Contributing 🙌🏽

Yes, I am willing to help solve this bug in a PR

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 69 (3 by maintainers)

Most upvoted comments

Can you guys try passing httpOptions with timeout like shown below (40000 is in ms)and check the error, now it won’t timeout because of openid-client, but you’ll see some error due to network issue with google/github auth server from there you can further check the issue.

GoogleProvider({
      clientId: process.env.GOOGLE_ID,
      clientSecret: process.env.GOOGLE_SECRET,
      httpOptions: {
        timeout: 40000,
      },
    }),

Is this still happening for everyone? It is happening for me, not only with google auth but also with github auth. Was anyone able to find a fix?

image Turn on the TUN Mode

I saw a question raised by someone in your repositories, and you answered it the same way. I have tried, but I still haven’t fixed it.

Same issue, cropped up randomly after working for days in dev (localhost). Works fine when deployed in prod. No changes were made whatsoever to the Nextauth config. Lengthened http timeout to 40s, same error. ‘outgoing request timed out after 40000ms’

No bug in sight, your Node.js process may not be able to reach google servers for a variety of local network / network setup related reasons.

This is happening to me with Email provider.

Hey everyone, I managed to fix the problem when running on WSL by upgrading NodeJS to v20.4.0. The timeouts are no longer happening on this version. If I downgrade it back to v18 or lower the timeouts come back. wsl -v WSL version: 1.2.5.0 Kernel version: 5.15.90.1 WSLg version: 1.0.51 MSRDC version: 1.2.3770 Direct3D version: 1.608.2-61064218 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.1992

No bug in sight, your Node.js process may not be able to reach google servers for a variety of local network / network setup related reasons.

This is the real reason, I use the clashX Pro for proxy, delete the localhost and 127.0.0.1 in the setting. Ignore proxy settings for these hosts and domains

Hi, @youngle316

Can you provide a detailed process? I am using Clash for Window and my GitHub login was successfully tested, but Google did not

This is my Clash related configuration:

mixed-port: 7890
allow-lan: false
external-controller: 127.0.0.1:49749
secret: e1af22c3-cc14-4c99-8bd1-f170a634d755
ipv6: false
image

Turn on the TUN Mode

you can import 'global-agent/bootstrap';

this happened with me while i was on “A” wifi. switched it to “B”, issue gone away 😭

I’m facing the same issue with the Google Provider too. Increasing the timeout doesn’t seem to do any good.

How is this closed? oO

I had this issue on wsl when I switched to windows, it worked as expected. maybe some kind of network issue with wsl?

Try NODE_DEBUG=http,https.

I am facing the same issue for the past 24 hours only, the same code worked fine earlier, and I have never encountered this issue before.

openid-client is not the source of your issue then

This is obviously a network issue, so why is it relevant to node?

same issue with me , tried many methods but no solution: tried method:

  1. Wifi restart
  2. using personal mobile data
  3. laptop restart
  4. changed timeout in nextauthoptions

Github provider works well, the problem is only with Google provider

using on wsl2 , window 11

WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.2134

Error message:

[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error outgoing request timed out after 3500ms {
  error: RPError: outgoing request timed out after 3500ms
      at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/openid-client@5.4.3/node_modules/openid-client/lib/helpers/request.js:115:19)
      at async Issuer.discover (webpack-internal:///(rsc)/./node_modules/.pnpm/openid-client@5.4.3/node_modules/openid-client/lib/issuer.js:135:30)
      at async openidClient (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.0_next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/lib/oauth/client.js:12:18)
      at async oAuthCallback (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.0_next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/lib/oauth/callback.js:94:24)
      at async Object.callback (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.0_next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/callback.js:18:79)
      at async AuthHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.0_next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:202:38)
      at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.0_next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:50:30)
      at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/.pnpm/next-auth@4.23.0_next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:84:24)
      at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/future/route-modules/app-route/module.js:254:37) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'google',
  message: 'outgoing request timed out after 3500ms'
}

I faced this issue a couple times with different providers and I get it to work by turning on/off my wifi connection in my laptop.

I had this issue on wsl when I switched to windows, it worked as expected. maybe some kind of network issue with wsl?

Hi, currently using WSL and facing this issue. Tried the timeout 40s as suggested but it doesn’t seem to work. How did you fix yours? I was thinking it’s an issue with the version of node i’m using.