Oauth callback url is including port when it shouldn't and not working

I have n8n setup on a Docker container, behind nginx (also running on docker).
I’ve setup both nginx and n8n to function through a dedicated subdomain.

The problem is, I can’t connect Google apps because the callback link that n8n is generating can’t be reached. That link is including the 5678 port but my n8n instance can only be reached via its default URL in https.

Here is how I run n8n:

docker run -d --name n8n \
  -v n8n_data:/home/node/.n8n \
  -e N8N_PROTOCOL="https" \
  -e N8N_HOST="n8n.preprod.bge-adil.eu" \
  -e VUE_APP_URL_BASE_API="https://n8n.preprod.bge-adil.eu/" \
  -e WEBHOOK_TUNNEL_URL="https://n8n.preprod.bge-adil.eu/" \
  --network custom_network \

The ngnx setup is as follow:

server {
    listen 80;
    server_name n8n.preprod.bge-adil.eu;
    return 301 https://$host$request_uri; # Force HTTPS
server {
    listen 443 ssl;
    server_name n8n.preprod.bge-adil.eu;

    ssl_certificate /etc/letsencrypt/live/preprod.bge-adil.eu/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/preprod.bge-adil.eu/privkey.pem;

    location / {
        proxy_pass http://n8n:5678/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;

I can connect and use n8n properly, but when I try to authenticate to the Youtube API, it gives me a callback URL with the port. If I try to reach that URL manually, it won’t work, surely because my nginx setup is forwarding traffic without that port:

When I try to authenticate using it anyway, it times out:

And I can’t reach the callback URL in my browser either.

If I provide google API with the callback URL without the port, I can reach it via browser but I get a mismatch error in n8n when trying to connect.



How can I make the authentication work for my installation?

Many thanks for any help!

Information on your n8n setup

  • n8n version: latest
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main): see above
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker + ngninx
  • Operating system: Linux (ionos cloud server)

Hello @bg_adl

Have you tried to set the WEBHOOK_URL env?
Configuration methods | n8n Docs

I don’t know where you have found the WEBHOOK_TUNNEL_URL as it’s not in the ENVs list


Oh god.
Thank you so much, such a stupid mistake on my part. It was this, I put the right ENV and now it’s working fine.

Thanks a lot, I was completely clueless :sob:

1 Like

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