Gmail Trigger not working (most of the time)

Describe the problem/error/question

Workflow with Gmail Trigger not working and very slow to publish

What is the error message (if any)?

The Gmail Trigger does not work reliably. I managed to get it working a few times, but most of the time it just doesn’t react to new messages anymore. In the computer where I’m running the n8n self-hosted, I see the following errors. This is a machine with very limited outbound connections, but I got it working at some point, so I don’t think that should be the problem.

Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at AxiosError.from (/home/angelv-adm/.npm-global/lib/node_modules/n8n/node_modules/axios/dist/node/axios.cjs:1355:24)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at RedirectableRequest.handleRequestError (/home/angelv-adm/.npm-global/lib/node_modules/n8n/node_modules/axios/dist/node/axios.cjs:4026:25)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at RedirectableRequest.emit (node:events:520:35)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at ClientRequest.eventHandlers. (/home/angelv-adm/.npm-global/lib/node_modules/n8n/node_modules/follow-redirects/index.js:56:24)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at ClientRequest.emit (node:events:508:28)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at emitErrorEvent (node:_http_client:108:11)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at TLSSocket.socketErrorListener (node:_http_client:575:5)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at TLSSocket.emit (node:events:520:35)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at emitErrorNT (node:internal/streams/destroy:170:8)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at emitErrorCloseNT (node:internal/streams/destroy:129:3)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at Axios.request (/home/angelv-adm/.npm-global/lib/node_modules/n8n/node_modules/axios/dist/node/axios.cjs:5427:41)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at processTicksAndRejections (node:internal/process/task_queues:104:5)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at invokeAxios (/home/angelv-adm/.npm-global/lib/node_modules/n8n/node_modules/@n8n/backend-network/src/http/axios/invoke.ts:15:10)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at httpRequest (/home/angelv-adm/.npm-global/lib/node_modules/n8n/node_modules/@n8n/backend-network/src/http/axios/request.ts:211:5)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at Object.request (/home/angelv-adm/.npm-global/lib/node_modules/n8n/node_modules/@n8n/backend-network/src/http/outbound-http.ts:188:12)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at paginatedRequest (/home/angelv-adm/.npm-global/lib/node_modules/n8n/src/utils/strapi-utils.ts:87:15)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at getCommunityNodeTypes (/home/angelv-adm/.npm-global/lib/node_modules/n8n/src/modules/community-packages/community-node-types-utils.ts:54:9)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at CommunityNodeTypesService.fetchNodeTypes (/home/angelv-adm/.npm-global/lib/node_modules/n8n/src/modules/community-packages/community-node-types.service.ts:93:13)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at CommunityNodeTypesService.getCommunityNodeTypes (/home/angelv-adm/.npm-global/lib/node_modules/n8n/src/modules/community-packages/community-node-types.service.ts:213:4)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at CommunityNodeTypesController.getCommunityNodeTypes (/home/angelv-adm/.npm-global/lib/node_modules/n8n/src/modules/community-packages/community-node-types.controller.ts:18:10)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: read ECONNRESET
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: Error: read ECONNRESET
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20)
Aug 01 10:20:33 orejon.ll.iac.es n8n[1375]: Error fetching from Strapi API (https://api-staging.n8n.io/api/community-nodes): read ECONNRESET
Aug 01 10:22:51 orejon.ll.iac.es n8n[1375]: There was a problem in ‘Gmail Trigger’ node in workflow ‘7’: ‘undefined’

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

Hi @angelv
Those ECONNRESET traces are n8n fetching the community node list from api-staging.n8n.io, not Gmail. “undefined” on the Gmail Trigger line means the poll’s call to Google died at the socket level, so there was no API response body to pull a message from, and a failed poll is skipped with no retry, which is why whole minutes of mail never arrive. Open outbound 443 to www.googleapis.com and oauth2.googleapis.com from that host. Test it from the box itself:

curl -sS -o /dev/null -w '%{http_code}\n' https://www.googleapis.com/gmail/v1/users/me/profile

401 is the healthy result, it means the host is reachable and only the token is missing. A connection error or a hang is the egress filter cutting it.
For the slow publishing, this stops n8n reaching out for community nodes on every editor load:

N8N_COMMUNITY_PACKAGES_ENABLED=false

curl seems fine:

angelv-adm@orejon:~$ curl -sS -o /dev/null -w ‘%{http_code}\n’ https://www.googleapis.com/gmail/v1/users/me/profile
401

I’m starting n8n with these variables set:

Environment=PATH=/home/angelv-adm/.npm-global/bin/:/usr/bin:/bin
Environment=GENERIC_TIMEZONE=Atlantic/Canary
Environment=NODES_EXCLUDE=“
Environment=N8N_HOST=orejon.ll.iac.es
Environment=N8N_PROTOCOL=https
Environment=N8N_PORT=5678
Environment=N8N_EDITOR_BASE_URL=https://orejon.ll.iac.es/
Environment=WEBHOOK_URL=https://orejon.ll.iac.es/
Environment=N8N_PROXY_HOPS=1
Environment=N8N_DIAGNOSTICS_ENABLED=false
Environment=N8N_VERSION_NOTIFICATIONS_ENABLED=false
Environment=N8N_TEMPLATES_ENABLED=false
Environment=N8N_ONBOARDING_FLOW_DISABLED=true
Environment=N8N_LICENSE_AUTO_RENEW_ENABLED=false
Environment=N8N_DIAGNOSTICS_CONFIG_FRONTEND=
Environment=N8N_DIAGNOSTICS_CONFIG_BACKEND=
Environment=EXTERNAL_FRONTEND_HOOKS_URLS=

but I I try to Fetch a test event I get a timeout error:

N8N_COMMUNITY_PACKAGES_ENABLED=false

I'm using "Execute Command" node, which I understand it will fail if I set this?

Hey @angelv

While you mentioned limited outbound connections, the specific error connect ETIMEDOUT 2001:4860:4840:400::443 reveals that n8n is attempting to connect to Google via IPv6​, and your network/machine is either not configured for IPv6 or the outbound firewall is dropping IPv6 packets.

The ECONNRESET errors in your logs regarding api-staging.n8n.io further confirm that your machine is struggling with stable outbound TLS connections to external APIs.

Since your machine has limited outbound connectivity and is failing on an IPv6 address, you need to force Node.js (and thus n8n) to prefer IPv4.

Add the following environment variable to your n8n startup configuration (where you set N8N_HOST, etc.):

Environment=NODE_OPTIONS=--dns-result-order=ipv4first

If you are using a systemd service file (which it looks like based on your Environment= snippets):

  1. Edit the service file: sudo nano /etc/systemd/system/n8n.service (or your specific filename).
  2. Add the line: Environment=NODE_OPTIONS=--dns-result-order=ipv4first.
  3. Reload systemd: sudo systemctl daemon-reload.
  4. Restart n8n: sudo systemctl restart n8n.

To confirm the fix is working outside of n8n, run this command from your terminal:

# Force IPv4 curl to Google API
curl -4 -v https://www.googleapis.com/gmail/v1/users/me/profile
  • If this returns 401 (Unauthorized): The network path is open (401 is expected because you aren’t passing a token).
  • If this still times out: Your outbound firewall is blocking port 443 to Google’s IP ranges entirely, and you must request the network admin to whitelist *.googleapis.com.

For other log errors

  • Error fetching from Strapi API... ECONNRESET: This is n8n trying to check for community node updates. It is unrelated to your Gmail workflow but confirms the general instability of your outbound connections. You can ignore this, or disable community node checks if possible.
  • There was a problem in ‘Gmail Trigger’... ‘undefined’: This is a generic crash resulting from the ETIMEDOUT mentioned in your screenshot. Once the IPv4 fix is applied, this should disappear.

Does this help?

No, that one is unrelated to Execute Command. N8N_COMMUNITY_PACKAGES_ENABLED only governs npm community node packages, the ones installed from the Community nodes settings page. Execute Command is a built-in core node and is gated separately by NODES_EXCLUDE, which you already have set to an empty array, so it keeps loading either way.

Thanks a lot. I don’t know how many times I have fallen into IPv6 problems in this network, but somehow it still it doesn’t click in my mind…

I added these to my service file, restarted, and immediately started getting results

Environment=NODE_OPTIONS=–dns-result-order=ipv4first
Environment=N8N_COMMUNITY_PACKAGES_ENABLED=false

Thanks a lot!

The IPv4 diagnosis looks right — but check WHERE you set NODE_OPTIONS. If n8n runs under systemd, exporting it in your shell or .bashrc never reaches the service. It has to be Environment=NODE_OPTIONS=–dns-result-order=ipv4first in the unit file (or an EnvironmentFile), then systemctl daemon-reload and restart.

Confirm it actually landed instead of assuming: sudo strings /proc/$(pgrep -f n8n | head -1)/environ | grep NODE_OPTIONS. If it isn’t in that output, the setting never applied, and that’s why nothing changed.