Free auditStart free
GuideError · CDN and hosting errors

Render 502 Bad Gateway

A Render 502 means your service could not handle the request: no good deploy, failing health checks, wrong host or port, or killed workers. Fixes with code.

5 min
read
7
sources
Oct 30, 2026
updated
Scaplet Editorial Team
author
In one line

On Render, a 502 Bad Gateway means your service isn't able to handle a request. Render's docs list the causes: the service never had a successful deploy, its only instance is failing health checks, it isn't bound to 0.0.0.0 and the PORT variable (default 10000), a new custom domain isn't routed yet, Node keep-alive timeouts, or workers killed for timing out. Match your logs to one, then apply that fix.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
02Fix it on your stack

Check it in 2 minutes

Run the CLI commands with the Render CLI installed and logged in. The curl lines work from anywhere, and the first one is against a public test service to show the output.
Public test endpoint: read a 502 status and time it
curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://httpbin.org/status/502
# observed: 502 1.77s   (the time is network latency, not a Render value)
Your service: compare the onrender.com URL with the custom domain (needs your URLs)
curl -sS -o /dev/null -w "onrender: %{http_code}\n" https://your-service.onrender.com/
curl -sS -o /dev/null -w "custom:   %{http_code}\n" https://www.your-domain.example/
# 200 and 502: a custom domain routing problem
# 502 and 502: the service itself
Your service: tail the logs (needs the Render CLI; command from the Render docs)
render logs --resources srv-abc123 --tail

Replace srv-abc123 with your service ID. Then look at the Events page for Instance Failed, because that event tells you whether the app exited with an exit code or Render restarted it after failed health checks.

03Check it

Fix the host and port

Render says a web service must bind to a port on host 0.0.0.0 to receive requests, and that the default expected port is 10000. It does not support IPv6 addresses. The safe pattern is to read the port from the PORT variable and bind early, before any slow start-up work, so the port scan finds it.

I ran this file locally with PORT=18080 and it logged listening on 0.0.0.0:18080 and answered 200 OK. For Gunicorn, the settings reference says that if the PORT environment variable is defined, the default bind is 0.0.0.0:$PORT, and that without it the default is 127.0.0.1:8000. So where Render defines PORT, a plain Gunicorn command should pick it up. A hard-coded --bind 127.0.0.1:8000 is the thing that breaks it.

Python: Gunicorn start command (adjust the module path)
gunicorn your_application.wsgi:application --bind 0.0.0.0:$PORT
Node.js: bind to 0.0.0.0 and the PORT variable
import http from 'node:http';

const port = Number(process.env.PORT) || 10000;
const server = http.createServer((req, res) => {
  res.end('ok\n');
});

server.listen(port, '0.0.0.0', () => {
  console.log(`listening on 0.0.0.0:${port}`);
});
05How it works

Fix health check failures

Render sends health checks to web and private service instances. By default they are TCP probes to an open port, and a check passes if the instance accepts the connection within five seconds. A web service can add an HTTP health check on a path of your choice; the instance passes when it answers with a 2xx or 3xx status within five seconds. Repeated failures on a live service trigger an automatic restart, and Render says not to restart a failed instance by hand while troubleshooting.
render.yaml: HTTP health check path
services:
  - type: web
    name: my-app
    runtime: node
    healthCheckPath: /healthz
  1. 01

    Add a cheap endpoint

    Return 200 from a route that checks only what the app needs to serve traffic. Render recommends operation-critical checks such as a simple database query.

  2. 02

    Keep it fast

    A check that takes longer than five seconds counts as a failure, so avoid calling slow third-party APIs from it.

  3. 03

    Exclude it from rate limiting

    Render's docs warn that an application rate limiter that counts custom health checks, which arrive every few seconds, can cause 429s. Skip the health path in your limiter.

  4. 04

    Watch metrics

    Check CPU and memory metrics. Render lists exhaustion of either as a cause of failing health checks.

Sources · 7

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • render.com
  • nodejs.org
  • gunicorn.org
  • google.com
  1. 01Render Docs: Troubleshooting Your Deployrender.com · checked 2026-11-01
  2. 02Render Docs: Web Servicesrender.com · checked 2026-11-01
  3. 03Render Docs: Health Checksrender.com · checked 2026-11-01
  4. 04Render Docs: Blueprint Specificationrender.com · checked 2026-11-01
  5. 05Node.js documentation: HTTPnodejs.org · checked 2026-11-01
  6. 06Gunicorn documentation: Settingsgunicorn.org · checked 2026-11-01
  7. 07How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01Why does my Render service return 502 right after deploy?

Render lists a few documented causes: the service has never had a successful deploy, its only instance is failing health checks, or it is not bound to host 0.0.0.0 and the port in the PORT variable, which defaults to 10000. Check the Events page and logs for which applies.

02Does the 502 on my custom domain mean my service is down?

Not necessarily. Render says a new custom domain that isn't redirecting to a web service yet can return 502, and that DNS changes usually propagate in a few minutes but can take up to an hour. Compare with the onrender.com URL.

03What does WORKER TIMEOUT mean on Render?

It is a log line from the app server, such as Gunicorn, saying a worker was killed for not responding in time. Render's guide ties these to 502s and says to increase the server's timeout setting, for example Gunicorn's timeout, which defaults to 30 seconds.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane