I have been using docker to run n8n and I have been caught in an interesting loop.
When using host port 5678 that is default I have not been able to access localhost:5678 as it refused to connect.
I have tried all methods of resolving the issues. Like checking the ports if they are being used already and many other things… but none has been the solution.
So, I decided to change the host port to 7889 while container port remained 5678. This opened n8n app and I logged in. Now when I was entering credentials for YouTube OAuth2 API. I saw OAuth Redirect URL using 5678 as host port.
I used the same URL for creating OAuth Client ID. Now after doing everything here’s what I get again, same message that localhost refused to connect.
To Reproduce
Ran n8n in Docker with default internal port 5678, but localhost:5678 refused to connect.
Changed host port to 7889 — accessed n8n at localhost:7889 successfully.
Started YouTube OAuth2 setup inside n8n.
n8n auto-generated redirect URL using port 5678:
http://localhost:5678/rest/oauth2-credential/callback
Used this URL in Google OAuth Client setup.
After authentication, browser redirected to localhost:5678, which again refused connection.
Expected behavior
n8n should generate the OAuth2 Redirect URL using the actual host port (e.g., 7889) instead of hardcoding 5678,
or
Allow users to manually configure the redirect port used in OAuth2 credentials.
Operating System
Windows 11
n8n Version
1.95.3
Node.js Version
22.16.0
Database
SQLite (default)
Execution mode
main (default)