OAuth Callback - localhost refused connection

Hi. Simple issue here. I saw some answers related but all were for people with web servers not RPI.
I’m now using version 0.122.1 on a raspberry pi but I’m having issues while trying to connect the API for ClickUp, Outlook etc.
After trying to connect I get localhost refused to connect. This is how it looks like on pc.

I also saw this default hosts-file config in the Pi seems a bit weird…

I already tried messing with the host files in the pi and pc, antivirus, firewall.
On PC http://localhost:5678/ doesn’t load either (certainly the reason why this issue exists). Only or http://n8n-pi:5678/ work.

I think replacing the callback to include my actual rpi could fix it?
from: http://localhost:5678/rest/oauth2-credential/callback
to something like
but how can this be done? and is there any other solution you may know about?
Thanks in advance

Hey @realstylishguy!

I haven’t tried this on an RPi, so I am not sure why you’re facing this issue. The localhost URI works fine on my machine. Maybe the services are not able to reach your local network? Did you try using ngrok?

What I understand to be the problem is that the URI says “localhost” but since im doing the OAuth from the PC… that “localhost” is not read as the RPI localhost but instead as the PC Localhost… and in the PC localhost:5678 there is nothing but goes directly to the pi…
I tried ngrok but it does not work because the hard coded callback url in n8n and the one generated by ngrok do not match.
I wonder if my problem is a design limitation or if it’s just me.

Can you try export WEBHOOK_TUNNEL_URL =https://ngrok-url?

@realstylishguy keep in mind that when setting the tunnel URL via env variables, the URL has to end with /. So following the example @harshil1712 provided, it has to be export WEBHOOK_TUNNEL_URL =https://ngrok-url/

I’ve tried… but I may not have the full configuration… Right now I installed n8n using this documentation for rpi here which doesn’t include any of the env configuration… I tried to make my raspberry work by adapting the server configuration using the regular documentation but it doesn’t really apply to me. That documentation is for amd64 arch not arm7 so I don’t really see how I can make this work. I even tried hosting it on my pc and doing the authentication and then importing the credential into my rpi but it won’t let me bacause it is encrypted in different devices. Any thoughts let me know. Again I tried the export WEBHOOK_TUNNEL_URL = https://ngrok-url-here/ but it doesn’t work and it’s highly likely because my rpi is missing part of the installation mentioned in documentation. (A documentation designed for subdomains.)


Unfortunately, my knowledge of RPi is limited. Maybe @Tephlon can help you out here.

1 Like

Hey @realstylishguy

This is sounding like a combination of services exposing the webhook and setting variables within the system to ensure that the proper webhook URL is exposed.

I don’t think this is specific to the RPi as I used the RPi instruction to install on a Debian-based system and it works fine.

I don’t have time at the moment to go into too many details on your specific challenges (I will dig into them a bit later) but I can provide you with a bit of a troubleshooting outline of how I would go about figuring out where the issues lie:

  1. Determine if the webhook service is working by creating a simple webhook and running the service that exposes the webhook (I think you mentioned ngrok). Resolve any issues around this.
  2. Manually update the environment variables with the correct WEB_HOOK URL value and ensure that it is available from command line. Resolve any issues around this.
  3. Stop n8n in PM2 and test it manually to see that it will give you the correct webhook URL. Resolve any issues around this.
  4. Restart n8n using PM2, ensuring that you are using the --update-env switch on the end of the command line. Resolve any issues around this.
  5. Configure your system to export the webhook URL environment variable on startup. Resolve any issues around this.
  6. Reconfigure PM2 to automatically start with all the proper environment variables (see Environment Variable Management for details). Resolve any issues around this.

This is the process that I would go through. Best of luck!