---
title: How do I debug a 502 error from a Vercel Serverless Function?
description: Information on how to debug a 502 error from a Vercel Serverless Function.
url: /kb/guide/how-to-debug-a-502-error
canonical_url: "https://vercel.com/kb/guide/how-to-debug-a-502-error"
published: 2025-11-03
last_updated: 2025-11-10
authors: Matthew Sweeney
related:
  - /docs/concepts/functions/serverless-functions
  - /docs/observability/log-drains
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---
<!-- docsgraph:related -->
## Related pages

> **For AI agents:** Follow these links to understand how this page connects to the rest of the Vercel ecosystem. For the full cross-link map (inbound, outbound, prerequisites, and semantic neighbors), see the .graph.md link below.

- [Debug Slow Functions](https://vercel.com/docs/functions/debug-slow-functions?from=related) — Diagnose and fix slow Vercel Functions using CLI tools, logs, and timing analysis.
- [Debug 500 Errors](https://vercel.com/docs/observability/debug-production-errors?from=related) — Find, fix, and verify production 500 errors using the Vercel CLI.
- [Functions](https://vercel.com/docs/functions?from=related) — Run server-side code on Vercel without managing a server.
- [Logs](https://vercel.com/docs/functions/logs?from=related) — Use runtime logs to debug and monitor your Vercel Functions.
- [What should I do if I receive a 503 error on Vercel?](https://vercel.com/kb/guide/what-should-i-do-if-i-receive-a-503-error-on-vercel?from=related) — Learn about when Serverless Functions return a 503 status code and what can be done about them.
- [Why does my Serverless Function work locally but not when deployed?](https://vercel.com/kb/guide/why-does-my-serverless-function-work-locally-but-not-when-deployed?from=related) — Learn how to troubleshoot your Serverless Functions.
- [How to debug 404 errors](https://vercel.com/kb/guide/how-to-debug-404-errors?from=related) — Learn the systematic steps to identify and resolve 404 issues.
- [Why does npm run start not work on Vercel?](https://vercel.com/kb/guide/npm-run-start-not-working?from=related) — Information on why commands that start servers may not work with Vercel.
- [How do I lower my Vercel Function execution time?](https://vercel.com/kb/guide/how-do-i-lower-my-serverless-function-execution-time?from=related) — Learn how to lower your Serverless Function execution time.

Full cross-link map for this page: [/kb/guide/how-to-debug-a-502-error.graph.md](/kb/guide/how-to-debug-a-502-error.graph.md)
<!-- /docsgraph:related -->


When [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) are throwing a 502 error, this means that no response is being received from the function. This is either due to the function taking too long to respond, or it has thrown an error.

## Debugging Deployment 502's

You can get instant feedback on why your Serverless Function is throwing a 502 error by looking at the [realtime request logs](https://vercel.com/knowledge/where-are-vercel-logs) for your deployment from the Vercel dashboard.

To do this, navigate and select your project on the Vercel dashboard then click "View Function Logs", from now on, until the page is closed, all requests made to Serverless Functions will generate a log. If any errors are present, these will be highlighted in Red.

## Log Drains

When you have a production deployment serving live traffic, it is critical to consider the usage of [Configurable Log Drains](https://vercel.com/docs/observability/log-drains#configure-a-log-drain) or [Log Drain Integrations](https://vercel.com/integrations?category=logging#logging). With one of those apps enabled, you will be able to see how long a function is taking to respond, error messages, status of responses, and other indicators.

## Debugging Locally

The easiest way to understand why your Serverless Function is throwing a 502 error is by running it locally either with `next dev`, if using Next.js, or `vercel dev` if not. Here you can replicate the steps taken before receiving the error and receive instant feedback in your terminal.

## Deploying Statically

If your deployment is not being statically generated at build time, you can change the structure of your application to do this.

Deploying a static site will provide you with a more reliable, available, and performant deployment as your user will be served content immediately, without waiting for page data to arrive and being served errors when content either takes too long or is sent in an incorrect format.