# How to Fix OAuth 400: redirect_uri_mismatch (Google / Slack) (2026 Verified Ubuntu/Docker Fix)

- URL: https://nodebudget.dev/errors/n8n-oauth-redirect-uri-mismatch-fix/
- Category: HTTPS & Caddy · Severity: Medium
- Author: Yuanqiang Leng (https://github.com/a895047059)
- Updated: 2026-11-26

## Exact Log Signature
`Error 400: redirect_uri_mismatch | callback URL shows http://localhost:5678`

## Root Cause
n8n generated an internal localhost callback URL because WEBHOOK_URL was missing or lacked https://.

## Verified Fix Commands
```bash
# Set exact public HTTPS domain in .env and restart:
WEBHOOK_URL=https://n8n.yourdomain.com/
N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com/
docker compose up -d --force-recreate n8n
```

## Permanent Production Prevention
Verify the OAuth Redirect URL shown in n8n Credentials starts with https:// before registering in Google Cloud Console.

---
Source: NodeBudget (https://nodebudget.dev/tools/error-decoder/)
