Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

489
Vistas
How to properly set nginx timeouts as proxy?

I am getting a few 502 errors in nginx:

2020/05/05 20:40:05 [error] 13425#0: *1360447 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.31.12.13, server: , request: "POST /app/functionHTTP/1.1", upstream: "http://127.0.0.1:8080/app/function", host: "example.com"

Architecture:

client - load balancer - instances (each with nginx proxy for NodeJS http server)

Timeout values:

  • client:

    • request timeout: 60s
  • load balancer:

    • keepalive timeout: 60s
  • nginx:

    • http keepalive_timeout: 65s
    • upstream keepalive_timeout: 60s
    • upstream keepalive: 256 connections
    • proxy_connect_timeout: 60s
    • proxy_read_timeout: 60s
    • proxy_send_timeout: 60s
  • server (NodeJS):

    • request timeout: 50s
    • keepAliveTimeout: 65s
    • headersTimeout: 70s

The 502 errors occur rarely (~0.01% of requests) but consistently.

What I've checked so far:

  • Limit of file descriptors not reached
  • Limit of nginx connections not reached
  • Limit of TCP ports not reached
  • Limit of CPU, memory, disk I/O not reached

It looks much like a race condition where the NodeJS server closed the connection and nginx is assuming the connection still exists.

What would be proper nginx timeout values in the current setting?

(I am unsure whether this isn't rather a question for ServerFault?)

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda