OAUTH2 Error - Localhost connection refused

N8N hosted in local RHEL server. We are accessing it from Windows Chrome browser using URL: http//10.13.138.19:5678. The URL http://localhost:5678 will not work.

While authenticating with Microsoft Outlook we are getting this error: This site can’t be reached localhost refused to connect. Redirect URL we are using: http://localhost:5678/rest/oauth2-credential/callback

From the previous questions in community i understood probably the error is happening because of Webhook URL.

Our questions are:

  • **How to change the Webhook in the already installed environment for Docker installation? The config file only has a encryption key
  • ** Which IP to use in the Webhook URL?

From the web UI the redirect URL is not changeable.

Command used for installation: docker run -d --restart unless-stopped --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n

Information on your n8n setup

  • **n8n version: 0.199
  • **Database you’re using (default: SQLite): Default
  • **Running n8n with the execution process [own(default), main]: Self hosted RHEL
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hi @saikatdas!

**How to change the Webhook in the already installed environment for Docker installation? The config file only has a encryption key

You’d need to set the webhook URL via the WEBHOOK_URL environment variable. So you’d first need to remove your running docker container, then start a new one with the -e parameter:

docker run -d --restart unless-stopped --name n8n -p 5678:5678 -e WEBHOOK_URL=http://10.13.138.19:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n

The new redirect URL should then show up in the UI:

Which IP to use in the Webhook URL?

It would need to be a valid URL accessible on the machine you are performing the authentication on. So based on your information I think http://10.13.138.19:5678 would do the job, though some services might require HTTPS redirects or valid public domain names. Microsoft should show you an error message though if they reject private IPs like the one you are using here.

Hi @MutedJam

Thanks for your quick reply. This is working perfectly.
Along with this i have found one more solution to work. When using redirect URL as localhost:5678 and when it gives error as refused to connect then we need to copy that authentication URL and paste it in a new tab. Change the URL from localhost to the internal IP and continue. It will show as authentication done. Comeback to the initial OAUTH tab and it will show Account Connected.

1 Like

Amazing, glad to hear this is now working for you. Thanks for confirming!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.