err:frontline:upstream:bad_gateway502 Bad Gateway.
Example response
If you’re calling an API hosted on Unkey
Retry with backoff. A single 502 during a rollout is normal. If every request fails this way, the app is unhealthy and only the API owner can fix it. Send them the request ID and the time.If you own this API
Your app accepted the connection and then closed it. If the gateway can’t connect at all, it tries your other instances first. It never retries a request your app already accepted, so your handlers don’t run twice for one request. Common causes:- The app crashed while handling the request.
- The instance was killed for running out of memory.
- The app closes idle connections too quickly.
- The app doesn’t speak the upstream protocol set for the deployment.
How to fix
- Read the runtime logs around the time of the request. Look for a crash, an out-of-memory kill, or a panic on the failing route.
- Make sure your app keeps connections open long enough for the gateway to reuse them.
- Check that your app handles the upstream protocol set for the deployment.
Related errors
err:frontline:upstream:service_unavailable: the instance refused the connection or couldn’t be reached.err:frontline:upstream:gateway_timeout: the instance didn’t answer in time.err:frontline:capacity:no_running_instances: there was no running instance to connect to.