I’m facing an issue while trying to set up Google OAuth2 credentials in n8n.
Setup Details:
- I’m self-hosting the latest n8n Docker image on AWS EC2 instance
- Im using a custom domain from namecheap.
- I’ve followed the official documentation and multiple tutorials to set up Google OAuth2 credentials.
- My OAuth Redirect URL in the Google Cloud Console is set to:
(http://localhost:5678/rest/oauth2-credential/callback)
The Problem
When I enter my Client ID and Client Secret in the n8n Google Calendar OAuth2 API node and proceed to sign in to my Google account, I:
- Select my Google account.
- Grant all the required permissions.
- Click “Allow.”
I’m taken to a page with the following error:
This site can’t be reached localhost refused to connect. ERR_CONNECTION_REFUSED
Yeah can not use localhost as redirect domain url.
Need to use ngrok or cloudflare tunnel to get a public accessible domain.
2 Likes
CAUSE
I have a domain setup but my docker env’s Webhook_URL was set to localhost:5678
SOLUTION
- Print your container env to check your webhook url
sudo docker exec -it <container_name_or_id> printenv
- If it isnt https://[domainname].com
sudo docker stop [container_name]
sudo docker rm n8n
- Replace the old one
sudo docker run -d \
--name n8n \
-e N8N_HOST=[domain] \
-e N8N_PORT=5678 \
-e WEBHOOK_URL=https://[domain].com \
-e N8N_SECURE_COOKIE=false \
-v n8n_data:/home/node/.n8n \
-p 5678:5678 \
n8nio/n8n
Add a google credential. The callback url should be
https://[domain]/rest/oauth2-credential/callback
1 Like
system
Closed
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.