Google calendar connect with 504 Gateway error

Describe the problem/error/question

The deployment is through Docker in Server, with version 1.41.0, and port 5678. The access method is public network access. The server uses Nginx for forwarding, utilizing https, and the access domain ht-tps:// is forwarded to the local server port 5678. In this case, the default OAuth Redirect URL will include the port, so the environment variable WEBHOOK_URL was set to ht-tps://, making the final Redirect URL: ht-tps://

There was a problem when attempting to perform Auth operations with Google Calendar, where the n8n callback returned a 504. Currently, it is unclear where the problem lies.

I have investigation:

  1. After completing the Google Calendar Auth steps, it will redirect to the corresponding n8n auth callback. ht-tps:// This indicates that the configuration in Google Cloud is correct.
  2. Direct access to ht-tps:// does get a corresponding response, so why is a 504 Gateway failure received after parameters are added?

I’ve done a lot of investigation but still haven’t found the root cause.

Can you provide more insights to help me identify the real root cause? Oh, by the way, I’ve only connected to Github and Google Auth so far, and Github is successfully connected.
@jan @ria Can you please help me solve this problem?

Information on your n8n setup

  • n8n version: 1.41.0
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: ubuntu 22.04

docker env

N8N_PORT 5678
N8N_VERSION 1.41.0
NODE_ENV production
NODE_ICU_DATA /usr/local/lib/node_modules/full-icu
PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHELL /bin/sh

also get this error log in nginx.

2024/05/14 12:13:09 [error] 64422#64422: *4296 upstream timed out (110: Unknown error) while reading response header from upstream, client:, server:, request: “GET /rest/oauth2-credential/callback?state=xxxxxx&scope= HTTP/2.0”, upstream: “”, host: “”, referrer: “

2024/05/14 12:34:01 [crit] 64422#64422: *4333 SSL_do_handshake() failed (SSL: error:0A00006C:SSL routines::bad key share) while SSL handshaking, client:, server:

get error in n8n docker log, seem not relate, but console when google auth.

2024-05-14T08:11:27.054149793Z at processTimers (node:internal/timers:512:7)
2024-05-14T08:11:27.053917916Z Error fetching feature flags Error [PostHogFetchNetworkError]: Network error while fetching PostHog
2024-05-14T08:11:27.054009671Z at new PostHogFetchNetworkError (/usr/local/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.js:740:16)
2024-05-14T08:11:27.054021139Z at step (/usr/local/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.js:135:27)
2024-05-14T08:11:27.054025114Z at Object.throw (/usr/local/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.js:84:53)
2024-05-14T08:11:27.054016776Z at PostHog. (/usr/local/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.js:1129:51)
2024-05-14T08:11:27.054028700Z at rejected (/usr/local/lib/node_modules/n8n/node_modules/posthog-node/lib/index.cjs.js:71:36)
2024-05-14T08:11:27.054043598Z at runNextTicks (node:internal/process/task_queues:60:5)
2024-05-14T08:11:27.054096155Z at listOnTimeout (node:internal/timers:538:9)
2024-05-14T08:11:27.054099812Z at processTimers (node:internal/timers:512:7) {
2024-05-14T08:11:27.054107850Z at Object.fetch (node:internal/deps/undici/undici:11731:11)
2024-05-14T08:11:27.054103969Z error: DOMException [TimeoutError]: The operation was aborted due to timeout
2024-05-14T08:11:27.054123460Z at runNextTicks (node:internal/process/task_queues:60:5)
2024-05-14T08:11:27.054127397Z at listOnTimeout (node:internal/timers:538:9)
2024-05-14T08:11:27.054130686Z at processTimers (node:internal/timers:512:7),
2024-05-14T08:11:27.054134786Z [cause]: DOMException [TimeoutError]: The operation was aborted due to timeout
2024-05-14T08:11:27.054142687Z at runNextTicks (node:internal/process/task_queues:60:5)
2024-05-14T08:11:27.054138532Z at Object.fetch (node:internal/deps/undici/undici:11731:11)
2024-05-14T08:11:27.054146365Z at listOnTimeout (node:internal/timers:538:9)
2024-05-14T08:11:27.054153397Z }
2024-05-14T08:12:30.095589515Z 2024-05-14T08:12:30.094Z [Rudder] error: Response error code: ETIMEDOUT
2024-05-14T08:15:19.418083079Z 2024-05-14T08:15:19.417Z [Rudder] error: Response error code: ECONNABORTED
2024-05-14T08:14:41.163668952Z 2024-05-14T08:14:41.162Z [Rudder] error: Response error code: ETIMEDOUT
2024-05-14T08:15:19.420856704Z 2024-05-14T08:15:19.420Z [Rudder] error: Error: ECONNABORTED
2024-05-14T08:15:19.424158272Z AxiosError: timeout of 37804.96899925597ms exceeded
2024-05-14T08:15:19.423411234Z AxiosError: timeout of 37804.96899925597ms exceeded
2024-05-14T08:15:19.424886807Z AxiosError: timeout of 37804.96899925597ms exceeded

hello @kangschampagne

I don’t like that part:

Seems that nginx is trying to pass the request to itself instead of the n8n server (but maybe it’s ok, I’m not familiar with nginx setup). Also, upstream has an HTTP protocol, but I see in the ENVs that you have set n8n to use HTTPS. Check the nginx configuration