# 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.

Canonical: https://scaplet.com/errors/cdn/render-502

Guide Render Error · CDN and hosting errors

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Frender-502%20(%22Render%20502%20Bad%20Gateway%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Frender-502%20(%22Render%20502%20Bad%20Gateway%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Frender-502%20(%22Render%20502%20Bad%20Gateway%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Frender-502%20(%22Render%20502%20Bad%20Gateway%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 6 parts, 5 minutes.

1. [The six causes Render documents 01](#the-six-causes-render-documents)
2. [Check it in 2 minutes 02](#check-it-in-2-minutes)
3. [Fix the host and port 03](#fix-the-host-and-port)
4. [Fix timeouts and killed workers 04](#fix-timeouts-and-killed-workers)
5. [Fix health check failures 05](#fix-health-check-failures)
6. [What a Render 502 does to search 06](#what-a-render-502-does-to-search)

_01_Documented causes and where they show up

## The six causes Render documents

A 502 on Render is the platform telling you it could not get your service to answer. The Troubleshooting Your Deploy guide groups the causes below, and each has a recognizable trace in the logs or events. Your first move is to find which row you are in, not to redeploy.

Cause

### The service has never had a successful deploy

Signal

No live deploy in the Dashboard event history

Fix

Get a deploy to succeed first; read the build and start logs

Cause

### The only instance is failing repeated health checks

Signal

Instance Failed events, sometimes with `connection refused` or `i/o timeout`

Fix

See the health check section below

Cause

### The web service has a misconfigured host or port

Signal

Logs show the server listening on `127.0.0.1` or another port

Fix

Bind to `0.0.0.0` and the `PORT` variable, default 10000

Cause

### A new custom domain is not routing to the web service yet

Signal

The `onrender.com` URL works but the custom domain gives 502

Fix

DNS changes usually propagate in a few minutes and can take up to an hour

Cause

### A Node.js service has intermittent timeouts or `Connection reset by peer`

Signal

Sporadic 502s, no crash

Fix

Increase `keepAliveTimeout` and `headersTimeout`

Cause

### Logs show `WORKER`, `SIGKILL` or `SIGTERM` warnings, such as `[CRITICAL] WORKER TIMEOUT`

Signal

Worker restarts in the logs

Fix

Increase the server timeout, for example Gunicorn's `timeout`

Request path: where a 502 can appear

```
browser or crawler | v Render (public routing for your onrender.com or custom domain) | never deployed / custom domain not routed yet -> 502 v service instance, bound to 0.0.0.0:$PORT | health checks failing, host or port wrong, | worker killed mid-request -> 502 v your app
```

_02_Fix 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
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)
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)
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.

_03_Check 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](/glossary/entity) that breaks it.

Python: Gunicorn start command (adjust the module path)

```
gunicorn your_application.wsgi:application --bind 0.0.0.0:$PORT
```

**Two listeners, one port**Render's docs also list conflicting port bindings as a start-up failure: if your start command already creates a server on a port, don't start another listener in your application code.

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}\`); });
```

_04_Defaults in the official docs

## Fix timeouts and killed workers

These two causes produce 502s without a crash, so they are easy to mistake for network noise. The Render guide's advice is to raise the relevant timeout. Defaults matter here, because the defaults are short.

Server

### Node.js `http`

Setting

`server.keepAliveTimeout`

Default

5000 ms (5 seconds)

Source

Node.js http docs

Server

### Node.js `http`

Setting

`server.headersTimeout`

Default

The minimum of `server.requestTimeout` or 60000

Source

Node.js http docs

Server

### Gunicorn

Setting

`timeout`

Default

30 seconds. Workers silent for longer are killed and restarted

Source

Gunicorn settings

Server

### Gunicorn

Setting

`keepalive`

Default

2 seconds. Behind a load balancer it often makes sense to set it higher

Source

Gunicorn settings

Node.js: raise keep-alive and header timeouts (example values)

```
const server = http.createServer(handler); server.keepAliveTimeout = 120_000; server.headersTimeout = 125_000;
```

Gunicorn: more time per worker, longer keep-alive (example values)

```
gunicorn your_application.wsgi:application \ --bind 0.0.0.0:$PORT --timeout 60 --keep-alive 75
```

The numbers above are examples, not Render values. Render's page says to increase them and does not give a target. Raise one setting, redeploy, and watch whether the `WORKER TIMEOUT` lines stop. If the worker is slow because of a long request, a bigger timeout only delays the kill, so also look at what the request is doing.

_05_How 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.

_06_Explained

## What a Render 502 does to search

Moving a live site to Render is where a 502 hurts most, because the old host may stop answering before the new custom domain routes. Google's [status code](/glossary/http-status-codes) guide classes 502 as a server error that slows crawling, with indexed URLs retained for a time and then dropped if the errors continue. Point DNS at Render before you retire the old host, and verify the status code on the custom domain, not only the onrender.com address. See [5xx server errors](/seo-issues/server-errors-5xx) and the general [502 Bad Gateway](/errors/http/502) page.

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. 01 [Render Docs: Troubleshooting Your Deploy](https://render.com/docs/troubleshooting-deploys) render.com · checked 2026-11-01
2. 02 [Render Docs: Web Services](https://render.com/docs/web-services) render.com · checked 2026-11-01
3. 03 [Render Docs: Health Checks](https://render.com/docs/health-checks) render.com · checked 2026-11-01
4. 04 [Render Docs: Blueprint Specification](https://render.com/docs/blueprint-spec) render.com · checked 2026-11-01
5. 05 [Node.js documentation: HTTP](https://nodejs.org/api/http.html) nodejs.org · checked 2026-11-01
6. 06 [Gunicorn documentation: Settings](https://gunicorn.org/reference/settings/) gunicorn.org · checked 2026-11-01
7. 07 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-11-01

Questions

## Asked a lot.

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

_01_ Why 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.

_02_ Does 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.

_03_ What 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.

## Keep learning

[All errors](/errors)

[Learn Cloud Run 503 error CDN and hosting errors](/errors/cdn/cloud-run-503) [Related 5xx server errors Status codes and links](/seo-issues/server-errors-5xx) [Read next Heroku H10: App crashed CDN and hosting errors](/errors/cdn/heroku-h10-app-crashed) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 502 errors
[AWS Lambda 502 Bad Gateway](/errors/cdn/aws-lambda-502) [Azure Front Door 502](/errors/cdn/azure-front-door-502) [Google Cloud 502 Bad Gateway](/errors/cdn/google-cloud-502) [502 Bad Gateway](/errors/http/502) [502 Bad Gateway in Apache](/errors/http/502/apache)

More in CDN and hosting errors
[CloudFront 404 Not Found](/errors/cdn/cloudfront-404) [CloudFront 503: Service Unavailable](/errors/cdn/cloudfront-503) [Firebase Hosting 404](/errors/cdn/firebase-hosting-404) [GitHub Pages 404 Not Found](/errors/cdn/github-pages-404) [Google Cloud 502 Bad Gateway](/errors/cdn/google-cloud-502) [Heroku 503 Service Unavailable](/errors/cdn/heroku-503) [Heroku H10: App crashed](/errors/cdn/heroku-h10-app-crashed) [Heroku H12: Request timeout](/errors/cdn/heroku-h12-request-timeout) [Heroku H13: Connection closed without response](/errors/cdn/heroku-h13) [Heroku H14: No web processes running](/errors/cdn/heroku-h14) [Netlify build failed](/errors/cdn/netlify-build-failed) [Netlify function timeout](/errors/cdn/netlify-function-timeout) [Render 502 Bad Gateway](/errors/cdn/render-502) [S3 Access Denied (403 Forbidden)](/errors/cdn/s3-access-denied) [Vercel 413: FUNCTION_PAYLOAD_TOO_LARGE](/errors/cdn/vercel-payload-too-large) [Vercel 429: Too Many Requests](/errors/cdn/vercel-429) [Vercel 500: Internal Server Error](/errors/cdn/vercel-500) [Vercel build failed](/errors/cdn/vercel-build-failed) [Vercel domain not working](/errors/cdn/vercel-domain-not-working) [Vercel FUNCTION_INVOCATION_TIMEOUT](/errors/cdn/vercel-function-invocation-timeout) [Vercel: too many redirects](/errors/cdn/vercel-too-many-redirects) [Akamai reference number](/errors/cdn/akamai-reference-number) [ALB 503 Service Unavailable](/errors/cdn/alb-503) [ALB 504 Gateway Timeout](/errors/cdn/alb-504-gateway-timeout)

Terms on this page
[Entity](/glossary/entity) [HTTP status codes](/glossary/http-status-codes)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
