<n8n version: 2.20.7
Database: SQLite (default)
Running via: Docker (self-hosted, Ubuntu 24.04 on DigitalOcean)
Reverse proxy: nginx with SSL via Certbot/Let’s Encrypt
Problem:
I have two self-hosted n8n instances:
Production: n8n.revvittsystems.com — Gmail OAuth works perfectly, including creating brand new credentials
Staging: staging.revvittsystems.com — Gmail OAuth fails with Error 400: redirect_uri_mismatch every time
Both instances run n8n 2.20.7 on Docker with nginx reverse proxy. Both use the same Google Cloud OAuth app (same Client ID/Secret). I also tried creating a completely separate OAuth client with only the staging redirect URI — same error.
What I’ve confirmed:
The redirect URI shown in n8n staging UI is https://staging.revvittsystems.com/rest/oauth2-credential/callback
This exact URI is registered in Google Cloud Console under Authorized redirect URIs
I decoded the Google error URL and confirmed the redirect_uri n8n sends is https://staging.revvittsystems.com/rest/oauth2-credential/callback — it matches exactly
X-Forwarded-Proto $scheme is set in nginx so n8n correctly generates https:// prefix
App is published to Production in Google OAuth consent screen
Tested in incognito window — same error
Creating a new credential on production works immediately — the Google OAuth app itself is fine
Creating a separate brand-new OAuth client just for staging also fails with the same error
Staging .env:
N8N_HOST=staging.revvittsystems.com
N8N_PORT=5678
N8N_PROTOCOL=https
WEBHOOK_URL=https://staging.revvittsystems.com/
N8N_EDITOR_BASE_URL=https://staging.revvittsystems.com
GENERIC_TIMEZONE=America/New_York
Staging nginx config:
server {
listen 443 ssl;
server_name staging.revvittsystems.com;
ssl_certificate /etc/letsencrypt/live/staging.revvittsystems.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/staging.revvittsystems.com/privkey.pem;
large_client_header_buffers 4 16k;
location / {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection ‘upgrade’;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_buffer_size 16k;
proxy_buffers 4 16k;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Additional note: When logged in as the owner/admin account on staging, clicking “Sign in with Google” gives a 414 URI Too Long error instead (known n8n bug where admin scopes are appended to the URL). Creating from a non-admin member account gets past the 414 but hits the redirect_uri_mismatch.
Question: What else could cause redirect_uri_mismatch when the URI is confirmed correct and matches exactly? Is there something specific about n8n 2.20.7’s OAuth flow that could cause this on a fresh instance?!-- Hey! The fastest way to find solutions is by using the
search function at the upper right.
If your question hasn’t been asked before, please follow the template below. Skip the questions that are not relevant to you.
You can post in any language - we’ll translate your post for you!
→
Describe the problem/error/question
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: