OAuth Callback URL is localhost:5678 link is not accessible

Describe the issue/error/question

trying to connect the google api to my n8n workflow and it requires to connect it using OAuth after configuring the OAuth on my GCP and input the details of the callback link from n8n, the link is not accessible.

What is the error message (if any)?

This site can’t be reached

localhost refused to connect.
ERR_CONNECTION_REFUSED

Hey @rodskie123,

How do you have n8n setup? At a guess it could be docker in which case localhost:5678 wouldn’t be available unless you were in the container itself.

You may need to set the WEBHOOK_URL environment variable which would allow you to use your domain name or IP depending on what you set it to.

Okay, do I need to install the docker-compose as well?

Hi Jon, by the way I start from the scratch again and run this command to install n8n on my server

docker run -it --rm \
        --name n8n \
        -p 5678:5678 \
        -v ~/.n8n:/home/node/.n8n \
        n8nio/n8n

after running this command, n8n is accessible on my browser but I got some issue with regards connecting to google api which is the Callback link from n8n so I end up to post new topic to ask some help…

Issue

Http://localhost:5678/rest/oauth2-credential/callback is not accessible

Hey @rodskie123,

You shouldn’t need compose as well but you would need to set the environment option for the host and webhook url you want to use.

It can be easier to use the compose option but you can pass options the same options usign the docker command line tool with the -e options.

1 Like

Apologize for the late reply, may I know do we have a guide for setting up an environment option for host and webhook url?

Also what are the variable needed to be add on environment option to fix the issue?

tried to run this command and assign URL to my env of my server but still callback link still not accessible

export WEBHOOK_URL=http://IPserver

Hi tried to add on my command -e

docker run -it --rm \
        --name n8n \
        -p 5678:5678 \
        -v ~/.n8n:/home/node/.n8n \
        -e N8N_PROTOCOL=http \
        -e N8N_HOST=localhost \
        -e N8N_PORT=5678 \
        -e WEBHOOK_URL=http://n8n.mytest.link \
        n8nio/n8n

still not able to access the callback link :frowning:

Did the call back URL change? Looking at the example for compose we provide the N8N_HOST is also set to the URL so N8N_HOST would be n8n.mytest.link

Did the call back URL change? Ans: Yes and I also update the URL in OAuth

I update the N8N_HOST but still not accessible

docker run -it --rm \
        --name n8n \
        -p 5678:5678 \
        -v ~/.n8n:/home/node/.n8n \
        -e N8N_PROTOCOL=http \
        -e N8N_HOST=n8n.automate.link \
        -e N8N_PORT=5678 \
        -e WEBHOOK_URL=http://n8n.automate.link:5678 \
        n8nio/n8n

Hey @rodskie123,

The URL changing is good, The question is are you using a URL that exists and that your computer can resolve?

when I’m accessing the URL set on N8N_HOST and WEBHOOK_URL its not accessible but when I access it using http://ServerIP:5678 I’m able to access n8n on my browser.

Have you set up anything to tell your machine that the URL you have set should resolve to the IP you are using? This would normally be a DNS record or for something local an entry in your hosts file. You should be able to just set the host and url to the IP as well.

I tried set on /etc/hosts

serverIP:5678 n8n.automate.link

is this correct?

You shouldn’t need the port just the IP and the hostname, Just don’t forget that you have put it there. Once you have it in there you can check to see if it will work with the nslookup command so something like nslookup n8n.automate.link

here’s the result when I run nslookup

** server can't find n8n.automate.link: NXDOMAIN

btw I added a port in hosts file, since when I try to lynx the 192.168.1.142 I access my another application… I also tried to remove it and execute nslook up I receive NXDOMAIN :frowning:

The port isn’t needed in the hosts file, To be honest I don’t even think it is something hosts files support. When you had the just the IP and n8n.automate.link in there did the nslookup work? Did you also make sure that the file was saved correctly and not saved as something like hosts.txt?

At this point it would probably be quicker to just use the IP of your machine in the environment variables, You did remember to change the hosts file on the right machine as well right? It would need to be changed on the machine you are using the browser on.