Issues with Google OAuth in n8n Docker Setup
Hello, I’m hosting n8n on my VPS and connected it to my subdomain. I can open it through this domain so I initially thought everything was working fine.
Now I wanted to connect my Google credentials and have done everything necessary.
Unfortunately, when signing in to my Google account, I get the following error: ‘ERR_CONNECTION_REFUSED’ when clicking the ‘Sign in with Google’ button.
I’ve already completed the following steps:
- Created a Google Cloud project and configured the OAuth credentials
- Set the OAuth Redirect URL in the Google Cloud Console to ‘https://my-domain.com:5678/rest/oauth2-credential/callback’
- In my docker-compose.yml, I have the following configuration:
- n8n with Traefik as reverse proxy
- Port 5678 exposed
- N8N_HOST and WEBHOOK_TUNNEL_URL correctly set
- Configured the firewall on my VPS so that port 5678 is accessible
When I directly ‘curl’ the callback URL, I get a response from the server, but the actual OAuth process doesn’t work.
Has anyone had similar problems or knows how to fix this? I suspect it has something to do with forwarding the OAuth requests through Traefik.
Here’s my docker-compose.yml for further reference:
version: "3"
services:
traefik:
image: "traefik:latest"
container_name: traefik
restart: always
command:
- "--api.insecure=false"
- "--providers.docker=true"
# More Traefik configuration
ports:
- "80:80"
- "443:443"
volumes:
- "./letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
n8n:
build:
context: .
dockerfile: Dockerfile
container_name: n8n-container
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_HOST=my-domain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_TUNNEL_URL=https://my-domain.com:5678
# More configuration

Thanks in advance for your help!