// guides · n8n error index

n8n OAuth2 redirect_uri_mismatch and callback errors: 18 tests, fixed

Why Google says redirect_uri_mismatch for n8n and how to fix it: where n8n gets its OAuth Redirect URL (localhost, the internal port, WEBHOOK_URL, N8N_EDITOR_BASE_URL), plus every callback error we triggered, from invalid_client to “The OAuth callback state is invalid!”. From 18 real runs on n8n 2.43.7.

Updated 2026-10-19 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. Copy the redirect URL from n8n

    Open the credential (for example Google OAuth2 API or Gmail OAuth2 API). n8n shows an OAuth Redirect URL such as https://n8n.example.com/rest/oauth2-credential/callback. This is the exact URL n8n sends to the provider. If it shows localhost or a port like :5678 on a server, fix n8n's settings first (step 2).

  2. Make n8n use your public address

    Set WEBHOOK_URL=https://your-domain/ (and, to be explicit, N8N_EDITOR_BASE_URL=https://your-domain/) and restart n8n. In our test, N8N_HOST plus N8N_PROTOCOL alone produced https://n8n.example.com:5812/..., with the internal port, which Google then rejects.

  3. Paste the exact URL into the provider

    In Google Cloud Console go to APIs & Services → Credentials, open the OAuth client (type Web application) and add the URL under Authorized redirect URIs. Same scheme, host, port and path, character for character. Save; Google says changes can take a few minutes to apply.

  4. Check Client ID and Secret

    A wrong Client ID stops at Google: “The OAuth client was not found. Error 401: invalid_client”. A wrong secret gets past Google and fails back in n8n with “Client authentication failed”. Copy both again from the same OAuth client.

  5. Connect from the right browser

    Click Connect my account (or Sign in with Google) while logged in to n8n at the public address, and allow the pop-up. A callback that lands in a browser not logged in to n8n gives Unauthorized, and reusing an old callback link gives The OAuth callback state is invalid!.

Where n8n gets the redirect URL

n8n builds the URL from its own settings, not from the address in your browser. On n8n 2.43.7 we started n8n with different settings and read the OAuth Redirect URL it showed, then created a Google credential and looked at the redirect_uri it actually sent to Google. The two always matched.

n8n settingsRedirect URL n8n usesWhat it means
No URL settings (plain n8n start on port 5811)http://localhost:5811/rest/oauth2-credential/callbackFine for local testing only: the callback only works in a browser on the machine n8n runs on.
N8N_HOST=n8n.example.com + N8N_PROTOCOL=https, n8n on port 5812 behind a proxyhttps://n8n.example.com:5812/rest/oauth2-credential/callbackThe internal port is added to the public URL. If you registered the URL without :5812, Google says redirect_uri_mismatch.
WEBHOOK_URL=https://n8n.example.com/ onlyhttps://n8n.example.com/rest/oauth2-credential/callbackCorrect. With no editor URL set, n8n uses the webhook URL for the editor and OAuth too.
N8N_EDITOR_BASE_URL=https://n8n.example.com onlyhttps://n8n.example.com/rest/oauth2-credential/callbackCorrect for OAuth, but webhook URLs still showed http://localhost:5814/. Set both.
N8N_EDITOR_BASE_URL with a trailing slashhttps://n8n.example.com/rest/oauth2-credential/callbackSame URL, no double slash. The trailing slash doesn't matter.
WEBHOOK_URL=https://n8n.example.com/ and N8N_EDITOR_BASE_URL=https://editor.example.com/ both set (Docker, n8n 2.43.7, 30 Oct)https://editor.example.com/rest/oauth2-credential/callbackN8N_EDITOR_BASE_URL wins. If the two differ, register the editor address in the provider, or make them the same.
WEBHOOK_URL=https://n8n.example.com/ + N8N_PATH=/n8n/ (Docker, 30 Oct)https://n8n.example.com/rest/oauth2-credential/callbackN8N_PATH was not added to the redirect URL. If your proxy serves n8n under a subpath, compare this URL with your real public path before pasting it into the provider.
N8N_PORT=443 to hide the portn8n refused to start: n8n does not have permission to use port 443. Please run n8n with a different port.Keep n8n on 5678 and set WEBHOOK_URL or N8N_EDITOR_BASE_URL instead.

For a server behind a reverse proxy on a normal HTTPS address, this is enough:

# docker-compose.yml (service n8n, environment)
- N8N_HOST=n8n.example.com
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://n8n.example.com/
- N8N_EDITOR_BASE_URL=https://n8n.example.com/

Restart n8n, open the credential again, copy the new OAuth Redirect URL and paste it into the provider (for Google: Google Cloud Console → APIs & Services → Credentials → your OAuth client → Authorized redirect URIs). The proxy itself must also pass the right host, see n8n “Connection lost” behind a reverse proxy.

Every callback error we triggered

Then we ran the sign-in itself: once against Google with a test client, and against a small local OAuth server that let us choose the answer. Each row is one run.

What happenedWhat n8n or Google showedFix
Google, with a client ID Google doesn't knowGoogle page “Access blocked: Authorization Error. The OAuth client was not found. Error 401: invalid_client”Copy the Client ID again from Google Cloud Console, with no spaces, and check it belongs to the project you think.
Callback opened with no parametersInsufficient parameters for OAuth2 callback. Received following query parameters: {}The provider didn't send a code back. Start again from Connect my account.
User clicks Cancel or Deny on the consent screen (error=access_denied)Same Insufficient parameters message, with "error":"access_denied" in the detailsNot a bug: accept the consent screen. On Google, an app in Testing only lets in the test users you added.
Callback with a broken stateInvalid state formatThe URL was cut or edited. Don't copy callback links by hand.
Valid callback opened in a browser that isn't logged in to n8nUnauthorizedOpen n8n and click Connect my account in the same browser, on the same address (not localhost in one tab and your domain in another).
The same callback opened a second timeThe OAuth callback state is invalid!Each sign-in link works once. Click Connect my account again.
Token exchange with a client Google doesn't know (real Google token endpoint), or a rejected secret (mock server)Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method). Details: invalid_clientPaste the Client Secret again. If you reset it in the provider, update n8n too.
Token endpoint answers invalid_grantThe provided authorization grant ... is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.The code expired or was already used, or the redirect URL changed between the two steps. Reconnect once, quickly.
Token endpoint answers redirect_uri_mismatchBad Request, details redirect_uri_mismatchn8n sends the same redirect URL again when it swaps the code for a token, so a wrong URL fails here too.
Token endpoint answers correctly“Connection successful. This window will close automatically in 5 seconds.”Done. The credential now holds an access token.
Token endpoint answers with no refresh_tokenAlso “Connection successful”n8n doesn't warn you. Without a refresh token it can't renew access when the token expires (we didn't wait for expiry).

Why it says redirect_uri_mismatch when the URL looks right

Google compares the URL character by character. In our runs the usual differences were a port (:5812) added by N8N_HOST, http instead of https, and localhost because no public URL was set. The sign-in pop-up's address contains the redirect_uri n8n sent, so you can compare it with the list in Google Cloud Console. Whatever n8n shows as OAuth Redirect URL is exactly what it sends: change n8n's settings, or add that exact URL to the provider, but make them identical.

Quick checklist

Good to know

What we didn't test

FAQ

How do I fix redirect_uri_mismatch in n8n?

Copy the OAuth Redirect URL shown in the n8n credential and add exactly that URL to the provider's allowed redirect URIs (Google Cloud Console, Credentials, your OAuth client). If n8n shows localhost or an internal port, set WEBHOOK_URL (or N8N_EDITOR_BASE_URL) to your public HTTPS address, restart n8n and copy the new URL.

Why does the n8n OAuth redirect URL show localhost?

n8n builds the redirect URL from its own settings, not from your browser. With no WEBHOOK_URL or N8N_EDITOR_BASE_URL set, it uses http://localhost:5678. Set one of them to your public address and restart.

Why does my n8n redirect URL contain :5678?

Setting N8N_HOST and N8N_PROTOCOL without a public URL keeps n8n's internal port in the address. In our test it gave https://n8n.example.com:5812/rest/oauth2-credential/callback. Set WEBHOOK_URL or N8N_EDITOR_BASE_URL to https://your-domain/ instead.

What does "The OAuth callback state is invalid!" mean?

The sign-in link was already used or is too old. Each Connect my account click creates a one-time link; click it again instead of reloading the callback page.

What does "Insufficient parameters for OAuth2 callback" mean?

The provider came back without an authorization code, usually because the consent screen was cancelled or denied (error=access_denied), or the account isn't allowed, such as a Google app in Testing without that user in its test users.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.