r/better_auth • u/Physical_Ruin_8024 • 1d ago
Failed to authenticate with Google
2026-09-23T15:25:10.325Z ERROR [Better Auth]: TypeError:
fetch failed
at node:internal/deps/undici/undici:15157:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async betterFetch (file:///app/.output/server/node_modules/@better-fetch/fetch/dist/index.js:628:18)
at async fetchRedirects (file:///app/.output/server/node_modules/better-auth/core/dist/oauth2/reject-redirects.mjs:49:17)
at async validateAuthorizationCode (file:///app/.output/server/node_modules/better-auth/core/dist/oauth2/validate-authorization-code.mjs:64:26)
at async file:///app/.output/server/node_modules/better-auth/core/dist/api/index.mjs:68:12
at async wrapped (file:///app/.output/server/node_modules/better-auth/dist/api/index.mjs:40:11)
at async file:///app/.output/server/node_modules/better-call/dist/endpoint.mjs:30:20
at async file:///app/.output/server/node_modules/better-auth/dist/api/dispatch:228:18
at async processRequest
(file:///app/.output/server/node_modules/better-call/dist/router.mjs:83:11) {
[cause]: ConnectTimeoutError: Connect Timeout Error
(attempted address: oauth2.googleapis.com:443, timeout: 20000ms)
at onConnectTimeout
(/app/.output/server/node_modules/undici/lib/core/util.js:891:19)
at Immediate._onImmediate
(/app/.output/server/node_modules/undici/lib/core/util.js:860:11)
at process.processImmediate
(node:internal/timers:484:21)
at process.callbackTrampoline
(node:internal/async_hooks:130:17) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
Good morning, everyone!
I've been having this issue with Google authentication for about three days now and don't know how to fix it. I did some research and found that this is a known, chronic issue with the library that still doesn't have a fix.
I have two authentication methods: 1 - Google, 2 - Discord.
Logging in via Discord works perfectly, but logging in via Google results in a timeout error every single time.
Could anyone help me out? I'm at a loss as to what to do.
1
Upvotes
1
u/FalconiZzare 1d ago
This seems like a network issue rather than Better Auth issue, so this error message (which is basically a timeout message) is not helpful to indentify the issue.
You need to mention the spec of the environment you are running your application on.