Error using Google Oauth2 for GMail

I’m attempting to create the Gmail OAuth2 API credentials and I followed the documentation detail by detail, but after giving the permission to the account I’m using, the login window ends with a “504 Gateway Time-out” error.
I also noticed my callback URL isn’t the usual I’m seeing in the other questions, but it’s something like “”.

By the way, I’m using n8n deployed in a Docker container (started with --tunnel), if that counts for something. Thanks!

Hi @Sfullez and welcome to the community!

The URL you have shared would be the tunnel URL you have requested when starting n8n with the --tunnel option. I’d highly recommend not to share it with anyone as it is a direct link to your personal n8n instance.

That said, I quickly gave this a go on my end but the auth flow was working as expected:

Following the confirmation in the above step 3 my user was authenticated as expected:

With a 504 indicating a gateway timeout it sounds like either your n8n instance or the tunnel server was not ready to accept the connection for whatever reason (or you have some very strict firewall in your network).

So as a first step you might simply want to try again. In case you still run into issues here, it’s worth checking whether your docker container is healthy when running into this.

Hi, thanks for the answer! I forgot to update it (my bad!), but everything went smoothly after I port-forwarded on my router the port used by my n8n instance: that was such a naive mistake I don’t know why it didn’t occur to me sooner…

And don’t worry, I set up that callback URL just for testing, now that I deployed my workflow there’s a different callback URL!
Thanks again!

1 Like

Awesome, I am glad to hear that! Thanks for reporting back :slight_smile:


I have a different problem that falls into the same category.
When trying to establish OAuth connection for Google apps from the n8n desktop app, everything runs well up to the point, where I have to sign in with google.
First, I get a warning, that the connection is insecure (though the OAuth redirect URL is https, but I guess that has something to do with the URL replacing :// with ASCII characters (?).
Second, when I continue and try to confirm all the permissions, I’m redirected and asked to log in…

Where’s my mistake?

Best regards, Mirko Schieder

Hi @Mirko_Schieder, welcome to the community and sorry to hear you’re having trouble. The username/password prompt is a peculiarity of the desktop app (which randomly generates such credentials to protect the tunnel it opens to receive data from external services) rather than a Google-specific problem. You can retrieve username and password as described here:

Hope this helps! Let me know if you’re having any trouble afterwards :slight_smile:

1 Like

Helped greatly!


1 Like