n8n Automation

Erori de Timeout la Webhook-uri n8n: Ghid Complet de Depanare

Petru Constantin
--6 min lectura
#n8n#webhook#timeout#troubleshooting#workflow-automation

Timeout-urile la webhook-uri sunt printre cele mai frecvente probleme in workflow-urile n8n. Acest ghid acopera toate scenariile de timeout si solutiile lor.

Intelegerea Timeout-urilor la Webhook-uri

Webhook-urile n8n pot da timeout in mai multe puncte:

External Service → Reverse Proxy → n8n Webhook → Workflow Processing → Response
     ↓                  ↓               ↓                ↓              ↓
  30-60s            60-120s          Default           Processing    Return
  timeout           timeout          60s timeout        time         result

Eroare: 504 Gateway Timeout

Simptom:

504 Gateway Timeout
The server didn't respond in time.

Cauza 1: Timeout la Reverse Proxy

Daca folosesti Nginx/Traefik/Caddy in fata n8n:

# Nginx - Increase timeout (nginx.conf)
location / {
    proxy_pass http://n8n:5678;
    proxy_connect_timeout 300s;
    proxy_send_timeout 300s;
    proxy_read_timeout 300s;
}
# Traefik - docker-compose.yml labels
labels:
  - "traefik.http.middlewares.n8n-timeout.buffering.maxRequestBodyBytes=50000000"
  - "traefik.http.middlewares.n8n-timeout.buffering.maxResponseBodyBytes=50000000"
  - "traefik.http.middlewares.n8n-timeout.buffering.retryExpression=IsNetworkError() && Attempts() < 3"
# Caddy
reverse_proxy n8n:5678 {
    transport http {
        dial_timeout 300s
        response_header_timeout 300s
    }
}

Cauza 2: Timeout-ul Default al Webhook-ului n8n

# Environment variable to increase n8n webhook timeout
N8N_DEFAULT_WEBHOOK_TIMEOUT=300000  # 5 minutes in milliseconds

Cauza 3: Workflow cu Executie Indelungata

Imparte procesarea intr-un pattern asincron:

// Webhook node - Respond Immediately
{
  "mode": "responseNode",
  "response": {
    "status": "accepted",
    "jobId": "{{$runId}}"
  }
}
 
// Later in workflow - Use "Respond to Webhook" node
// This sends the actual result

Eroare: ETIMEDOUT / Connection Refused

Simptom:

Error: connect ETIMEDOUT 192.168.1.100:5678
Error: connect ECONNREFUSED 127.0.0.1:5678

Cauza 1: n8n Nu Ruleaza

# Check n8n status
docker ps | grep n8n
# or
systemctl status n8n
 
# Check logs
docker logs n8n --tail 100

Cauza 2: URL Webhook Gresit

Verifica structura URL-ului webhook:

# Production URL (with N8N_HOST and N8N_PROTOCOL)
https://your-domain.com/webhook/abc123

# Test URL (different path!)
https://your-domain.com/webhook-test/abc123

# Common mistake - using test URL in production
https://n8n.yourdomain.com/webhook-test/abc123  # ❌ Won't work when workflow inactive

Cauza 3: Firewall/Security Group

# Check if port is open
curl -v https://your-n8n-instance.com/webhook/your-webhook-id
 
# Test from inside container/network
docker exec n8n wget -O- http://localhost:5678/healthz

Eroare: Request Entity Too Large

Simptom:

413 Request Entity Too Large
PayloadTooLargeError: request entity too large

Solutie:

# Increase payload limit (default is 16MB)
N8N_PAYLOAD_SIZE_MAX=64  # In megabytes
 
# For file uploads, also set:
WEBHOOK_MAX_UPLOAD_SIZE=64
# Nginx configuration
client_max_body_size 64M;

Eroare: Webhook Not Found (404)

Simptom:

404 Not Found
Webhook not found

Cauza 1: Workflow-ul Nu Este Activ

// Check workflow status via API
fetch('https://your-n8n/api/v1/workflows', {
  headers: {
    'X-N8N-API-KEY': 'your-api-key'
  }
})

Activeaza workflow-ul din interfata n8n sau prin API.

Cauza 2: Folosesti URL-ul de Test in loc de cel de Productie

| Mod | Cale URL | Cand se foloseste | |------|----------|-------------| | Test | /webhook-test/ | Dezvoltare, testare triggere | | Productie | /webhook/ | Workflow-uri live, integrari externe |

Cauza 3: ID-ul Webhook-ului s-a Schimbat

Cand stergi si recreezi un nod webhook, primeste un ID nou. Actualizeaza toate integrarile.

Optimizarea Timpului de Raspuns al Webhook-ului

Pattern 1: Raspuns Imediat + Procesare Asincrona

[Webhook] → [Set Response] → [Respond to Webhook] → [Heavy Processing]
                                      ↓
                              Returns immediately

Configurarea nodului:

// Respond to Webhook node
{
  "respondWith": "firstIncomingItem",
  "responseCode": 202
}

Pattern 2: Procesare Bazata pe Coada

[Webhook] → [Add to Queue] → [Response: "Queued"]
                   ↓
            [Separate Queue Worker Workflow]

Folosind o coada Redis:

// Function node - Add to Redis queue
const redis = require('redis');
const client = redis.createClient(process.env.REDIS_URL);
 
await client.lPush('webhook-jobs', JSON.stringify({
  id: $runId,
  payload: $input.all(),
  timestamp: Date.now()
}));
 
return [{ json: { status: 'queued', jobId: $runId } }];

Pattern 3: Timeout Webhook cu Logica de Retry

Serviciul extern care apeleaza webhook-ul tau:

// Caller-side retry logic
async function callN8nWebhook(payload, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      const response = await fetch('https://n8n.example.com/webhook/xxx', {
        method: 'POST',
        body: JSON.stringify(payload),
        headers: { 'Content-Type': 'application/json' },
        signal: AbortSignal.timeout(30000) // 30 second timeout
      });
      return await response.json();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      await new Promise(r => setTimeout(r, 1000 * Math.pow(2, i))); // Exponential backoff
    }
  }
}

Probleme Specifice Docker/Self-Hosted

Limite de Memorie

# docker-compose.yml
services:
  n8n:
    image: n8nio/n8n
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 512M
    environment:
      - NODE_OPTIONS=--max-old-space-size=1536

Connection Pooling

# Increase connection limits for high-traffic webhooks
N8N_METRICS=true
N8N_METRICS_PREFIX=n8n_
DB_POSTGRESDB_POOL_SIZE=20

Verificarea Health Check

# docker-compose.yml
healthcheck:
  test: ["CMD", "wget", "-q", "--spider", "http://localhost:5678/healthz"]
  interval: 30s
  timeout: 10s
  retries: 3
  start_period: 30s

Depanarea Problemelor de Timeout

Activeaza Logging Detaliat

# Environment variables
N8N_LOG_LEVEL=debug
N8N_LOG_OUTPUT=console,file
N8N_LOG_FILE_LOCATION=/home/node/.n8n/logs/n8n.log

Traseaza Cererea Webhook

# Test webhook with timing
curl -w "@curl-format.txt" -X POST \
  -H "Content-Type: application/json" \
  -d '{"test": true}' \
  https://your-n8n/webhook/your-id
 
# curl-format.txt contents:
#     time_namelookup:  %{time_namelookup}s\n
#        time_connect:  %{time_connect}s\n
#     time_appconnect:  %{time_appconnect}s\n
#    time_pretransfer:  %{time_pretransfer}s\n
#       time_redirect:  %{time_redirect}s\n
#  time_starttransfer:  %{time_starttransfer}s\n
#                     ----------\n
#          time_total:  %{time_total}s\n

Monitorizeaza Timpul de Executie al Workflow-ului

// Code node at start
$workflow.staticData.startTime = Date.now();
return $input.all();
 
// Code node at end
const duration = Date.now() - $workflow.staticData.startTime;
console.log(`Workflow execution time: ${duration}ms`);
return $input.all();

Referinta Rapida: Setari de Timeout

| Componenta | Variabila de Mediu | Default | Recomandat | |-----------|---------------------|---------|-------------| | n8n Webhook | N8N_DEFAULT_WEBHOOK_TIMEOUT | 60000ms | 300000ms | | Nginx | proxy_read_timeout | 60s | 300s | | Traefik | responseForwarding.flushInterval | 100ms | 100ms | | Docker | healthcheck.timeout | 30s | 60s | | HTTP Request Node | Setare din nod | 300000ms | Specific workflow-ului |

Cand sa Contactezi Suportul

Daca ai incercat tot ce e descris mai sus si tot ai probleme de timeout:

  1. Colecteaza log-urile n8n din momentul timeout-ului
  2. Noteaza timestamp-ul exact si ID-ul workflow-ului
  3. Documenteaza topologia retelei (proxy-uri, load balancere)
  4. Captureaza output-ul curl cu timing

Echipa noastra te poate ajuta sa diagnostichezi scenarii complexe de timeout care implica servicii multiple, infrastructura custom sau procesare de webhook-uri cu volum mare.

Obtine suport expert n8n


Sistemul tau AI e conform cu EU AI Act? Evaluare gratuita de risc - afla in 2 minute →

Ai nevoie de ajutor cu conformitatea EU AI Act sau securitatea AI?

Programeaza o consultatie gratuita de 30 de minute. Fara obligatii.

Programeaza un Apel

Weekly AI Security & Automation Digest

Get the latest on AI Security, workflow automation, secure integrations, and custom platform development delivered weekly.

No spam. Unsubscribe anytime.