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
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.
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.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
connection refused or i/o timeout127.0.0.1 or another port0.0.0.0 and the PORT variable, default 10000onrender.com URL works but the custom domain gives 502Connection reset by peerkeepAliveTimeout and headersTimeoutWORKER, SIGKILL or SIGTERM warnings, such as [CRITICAL] WORKER TIMEOUTtimeoutbrowser 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 appcurl lines work from anywhere, and the first one is against a public test service to show the output.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)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 itselfrender logs --resources srv-abc123 --tailReplace 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.
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.
gunicorn your_application.wsgi:application --bind 0.0.0.0:$PORTimport 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}`);
});httpserver.keepAliveTimeouthttpserver.headersTimeoutserver.requestTimeout or 60000timeoutkeepaliveconst server = http.createServer(handler);
server.keepAliveTimeout = 120_000;
server.headersTimeout = 125_000;gunicorn your_application.wsgi:application \
--bind 0.0.0.0:$PORT --timeout 60 --keep-alive 75The 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.
services:
- type: web
name: my-app
runtime: node
healthCheckPath: /healthzReturn 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.
A check that takes longer than five seconds counts as a failure, so avoid calling slow third-party APIs from it.
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.
Check CPU and memory metrics. Render lists exhaustion of either as a cause of failing health checks.
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 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 and the general 502 Bad Gateway page.
3 questions people ask next, answered from the sources on this page.
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.
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.
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.
Run the free audit, then approve the fixes. Every change can be undone.