Guides / n8n × Salesforce / Authentication

Fix “redirect_uri Must Match Configuration” Connecting Salesforce to n8n

The exact place two URLs have to match character-for-character when a Salesforce Connected App rejects n8n's OAuth callback, including the http vs https and trailing-slash mistakes that cause it.

Illustrated diagram comparing the OAuth redirect URL in n8n against the callback URL configured in a Salesforce Connected App.
error=redirect_uri_mismatch&error_description=redirect_uri must match configuration
Short answer: Salesforce compares the redirect_uri byte for byte against the Callback URL list on the Connected App. Scheme, host, port, path, and trailing slash all count, and no normalisation is applied. Read the exact value from the OAuth Redirect URL field in the n8n credential, paste it into the Connected App as an additional line, wait for the change to propagate — Salesforce documents several minutes, and up to about ten for a newly created app — and start a fresh authorization rather than retrying a stale browser tab.

Where each URL comes from

n8n generates a redirect URL automatically based on your instance: for n8n Cloud it is typically https://oauth.n8n.cloud/oauth2/callback, and for a self-hosted instance it is derived from your configured webhook/editor base URL, usually ending in /rest/oauth2-credential/callback. You can see the exact value n8n will send by opening the Salesforce credential in n8n and looking at the "OAuth Redirect URL" field — it is shown to you, not something you type in.

That exact string then has to be added to the Salesforce Connected App under Setup → App Manager → your app → Edit → API (Enable OAuth Settings) → Callback URL. This field accepts multiple URLs, one per line, so adding a new one for n8n does not remove any existing callback URLs used by other integrations.

Copy the redirect URL out of n8n and paste it directly into Salesforce. Retyping it by hand is the single most common way this mismatch happens — a missed hyphen or a different subdomain is invisible at a glance.

The specific mismatches that trigger this error

  • http:// vs https:// — a self-hosted n8n instance behind a reverse proxy sometimes reports its own base URL as http even though the public URL is https, or the other way around.
  • Trailing slash difference — https://your-n8n.com/rest/oauth2-credential/callback vs the same URL with a trailing slash are treated as different strings by Salesforce.
  • www vs no-www, or a different subdomain than the one your users actually browse to (e.g. the Callback URL was added for app.example.com but n8n's public URL is n8n.example.com).
  • A stale URL left over from before N8N_HOST, N8N_PROTOCOL, or WEBHOOK_URL environment variables were changed on a self-hosted instance — n8n will generate a new redirect URL from the new settings, but the old one is still the only one saved in Salesforce.

n8n Cloud vs self-hosted: what to actually paste

On n8n Cloud, the redirect URL is fixed and identical for every workspace on the same region: https://oauth.n8n.cloud/oauth2/callback (or the equivalent for the EU cloud region, if that's where your instance is hosted — check the field in n8n directly rather than assuming). Add exactly that value once, and it will work for every Salesforce credential you create in that workspace.

On a self-hosted instance, the redirect URL depends entirely on how the instance's public URL is configured (via N8N_EDITOR_BASE_URL, WEBHOOK_URL, or N8N_HOST/N8N_PROTOCOL/N8N_PORT depending on your n8n version). If you changed domains, moved from HTTP to HTTPS behind a new reverse proxy, or moved from a port-based URL to a clean domain, the redirect URL n8n now generates has changed — even though the Connected App still has the old one saved.

# Self-hosted n8n: confirm what redirect URL it currently generates
# (open the Salesforce credential in the n8n editor and read the
# "OAuth Redirect URL" field directly — do not guess from env vars alone,
# since precedence between them differs by n8n version)

After adding the correct Callback URL

Verify the comparison rather than eyeballing it. The authorization URL your browser was sent to contains the redirect_uri as a query parameter, so you can read exactly what n8n sent: open the failed OAuth popup, copy the full URL from the address bar, and decode the redirect_uri parameter. Compare that decoded string to the Callback URL line in Salesforce character by character. This takes a minute and settles the question definitively, where comparing two fields in two browser tabs does not.

Invisible characters are the most common reason two identical-looking strings fail the comparison. A callback URL pasted from a chat client or a document can carry a non-breaking space, a zero-width character, or a smart quote. Paste both values into a plain-text editor and check their lengths; if they differ, retype the Salesforce line by hand rather than hunting for the character.

Then start the authorization over from the beginning. Close the failed popup, reload the n8n credential page, and click Connect again. Salesforce caches nothing useful here, but browsers do cache the OAuth state, and retrying inside the tab that already failed reproduces the original request including the original redirect_uri.

# Decode what n8n actually sent, from the failed popup URL
https://login.salesforce.com/services/oauth2/authorize
  ?response_type=code
  &client_id=3MVG9...
  &redirect_uri=https%3A%2F%2Fn8n.example.com%2Frest%2Foauth2-credential%2Fcallback
  &state=...

# decoded: https://n8n.example.com/rest/oauth2-credential/callback

# These are four DIFFERENT values to Salesforce:
#   https://n8n.example.com/rest/oauth2-credential/callback
#   https://n8n.example.com/rest/oauth2-credential/callback/     <- trailing slash
#   http://n8n.example.com/rest/oauth2-credential/callback       <- scheme
#   https://www.n8n.example.com/rest/oauth2-credential/callback  <- host

# Confirm which org and user you ended up connected to, after it works:
GET https://login.salesforce.com/services/oauth2/userinfo
Authorization: Bearer ACCESS_TOKEN
# -> {"user_id":"005...","organization_id":"00D...","urls":{...}}

Connected App settings that block the callback even when the URL matches

A byte-perfect Callback URL is necessary but not always sufficient. Three other Connected App settings produce a failure at the same point in the flow. If Permitted Users is set to "Admin approved users are pre-authorized", the account you are authorizing in n8n must belong to a profile or permission set that has been assigned the Connected App, otherwise Salesforce refuses the callback. If "Require Proof Key for Code Exchange (PKCE)" is enabled on the Connected App but the credential type in n8n does not send a code challenge, the authorization is rejected before the redirect completes. And IP or login-hour restrictions on the authorizing user's profile can stop the callback from the server n8n authorized on.

Propagation timing is the other trap. Salesforce states that changes to a Connected App can take several minutes to take effect, and a newly created Connected App can take up to about ten minutes before it will accept an authorization at all. Saving the Callback URL and immediately retrying often reproduces the same error simply because the change has not propagated yet.

Finally, if two Connected Apps in the same org carry the same Callback URL, Salesforce can resolve the request against the wrong app, whose OAuth policy or scopes then reject it. Keep the n8n redirect URL on exactly one Connected App.

  • Permitted Users = pre-authorized: the authorizing user must be assigned to the app via profile or permission set.
  • PKCE required on the app but not sent by the credential: authorization fails before the redirect.
  • Wait 2-10 minutes after saving (or up to ~10 minutes after creating) the Connected App before retrying.
  • Do not reuse the same Callback URL across multiple Connected Apps in one org.

Self-hosted: the redirect URL is derived, so fix the derivation

On a self-hosted instance the redirect URL is not a setting you type — n8n builds it from the instance's configured public address. Behind a reverse proxy that terminates TLS, the container commonly sees plain HTTP on an internal port and generates an http:// redirect URL for a service the world reaches over https://. The credential page then shows you a URL that is genuinely what n8n will send and genuinely not what your users browse to.

Set the public base explicitly rather than letting it be inferred. With that in place, restart n8n, reopen the credential, and re-read the OAuth Redirect URL field — if it did not change, the value in the field is what n8n will send and the environment variable is not the one your version uses. Trust the field over the environment; it is the value that actually goes into the request.

One more consequence worth planning for: the redirect URL changes whenever the instance's public address changes. A domain migration, a move from a port-based URL to a clean hostname, or a switch from HTTP to HTTPS all invalidate every OAuth credential on the instance at once. Add the new callback URL to the Connected App before the migration, leave the old one in place until every credential has been reconnected, and remove it afterwards.

# docker compose — make the public address explicit
environment:
  - N8N_HOST=n8n.example.com
  - N8N_PROTOCOL=https
  - N8N_PORT=443
  - WEBHOOK_URL=https://n8n.example.com/
  - N8N_EDITOR_BASE_URL=https://n8n.example.com/

# Salesforce Connected App > Callback URL accepts one per line.
# During a migration, keep both until every credential is reconnected:
https://old-n8n.example.com/rest/oauth2-credential/callback
https://n8n.example.com/rest/oauth2-credential/callback

References used here

The Connected App Callback URL location and n8n's OAuth Redirect URL field come from n8n's Salesforce credentials documentation. The exact redirect_uri_mismatch error text and its resolution (matching the Callback URL exactly to n8n's generated redirect URL) are confirmed by a report on the n8n Community forum describing this same connection failure.

Frequently asked questions

Can I add my n8n redirect URL as one of several Callback URLs in the same Connected App?

Yes. The Callback URL field in a Salesforce Connected App accepts multiple URLs, one per line. Adding n8n's redirect URL does not remove or affect any existing callback URLs used by other tools connected to the same app.

I moved my self-hosted n8n to a new domain and Salesforce broke — why?

n8n generates its OAuth redirect URL from the instance's configured public URL. Moving domains changes that generated URL, but the Salesforce Connected App still only has the old Callback URL saved. Open the credential in n8n, copy the new redirect URL, and add it to the Connected App's Callback URL list.

Does the redirect URI need to match exactly including https vs http?

Yes. Salesforce compares the redirect_uri as an exact string, including the protocol, subdomain, path, and trailing slash. Any difference — even one that looks cosmetic — produces the mismatch error.

The two URLs look identical and it still fails.

Decode the redirect_uri parameter from the failed authorization URL and compare string lengths in a plain-text editor. A non-breaking space or zero-width character pasted in from a chat client is invisible on screen and fails Salesforce's byte-for-byte comparison.

It worked yesterday and broke after a deployment.

Self-hosted n8n derives the redirect URL from its configured public address. A change to the hostname, scheme, or port changes the generated URL, so the Connected App now holds only the old one. Add the new callback URL and reconnect the credential.