n8n: Retry a 429 or a 500, Fail Fast on a 401. HTTP Status Codes, Retry On Fail and the Error Output
说明与用途
在 n8n 中,仅对 429 和 5xx 进行重试,对 4xx 立即失败,并通过 Gmail 发送警报,避免隐藏错误和不必要的重试。
问题
An n8n workflow often fails because a supplier’s server is busy (429/500) or an API key has expired (401/403), causing silent retries or missed alerts.
结果
The workflow now retries only for transient server errors, fails fast on authentication or client errors, and alerts the owner via email, preventing silent failures and unnecessary retries.
工作流
- Configure HTTP Request node to include response headers and never error
- Set Retry On Fail to true, Max Tries 3, Wait Between Tries 5000ms
- Add a Code node to inspect statusCode and decide action
- If statusCode 200‑299: continue
- If 429 or >=500: retry up to 3 times, respecting Retry‑After header
- If 400,401,403,404: fail and send Gmail alert
- Wire Error output to Gmail Send a message node
证据
The most common way an n8n workflow fails in a small business isn't a bug. It's a supplier's server being busy at 6 AM.
Retry On Fail doesn't look at the code. A 401 gets retried three times, five seconds apart, exactly like a 503.
In the HTTP Request node, under Options, Response, turn on Include Response Headers and Status and Never Error.
- 记录日期: 2026-10-23T16:26:10.211Z