---
title: Troubleshooting Vercel Functions
product: vercel
url: /docs/functions/troubleshooting
canonical_url: "https://vercel.com/docs/functions/troubleshooting"
last_updated: 2026-11-17
type: how-to
prerequisites:
  - /docs/functions
related:
  - /docs/functions/debug-slow-functions
  - /docs/functions/limitations
  - /docs/errors
  - /docs/observability/debug-production-errors
  - /docs/logs/runtime
summary: Diagnose errors in Vercel Functions, including ECONNRESET errors when a function calls an external API or database.
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
---

# Troubleshooting Vercel Functions

Use this page to diagnose errors that your Vercel Functions log at runtime. For other problems, start with the page that matches the symptom:

| Symptom                                                                    | Where to look                                                              |
| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| The function responds slowly or times out                                  | [Debugging slow Vercel Functions](/docs/functions/debug-slow-functions)    |
| The function exceeds a size, memory, or duration limit                     | [Vercel Functions limits](/docs/functions/limitations)                     |
| The response is a Vercel error code, such as `FUNCTION_INVOCATION_FAILED`  | [Error codes](/docs/errors)                                                |
| Production returns errors and you don't know which function is responsible | [Debugging production errors](/docs/observability/debug-production-errors) |

## ECONNRESET errors

`ECONNRESET` means "connection reset by peer". Your function opened a connection to another server, such as an API or a database, and that server or a device on the network path closed the connection before the request finished. The cause is usually the external service or how the function connects to it.

With `fetch` in the Node.js runtime, the error appears in your [runtime logs](/docs/logs/runtime) as `TypeError: fetch failed`, and the `cause` property of the error has the code `ECONNRESET`.

### Common causes

How often the error occurs narrows down the cause:

- **Every request fails:** The connection is misconfigured. Check the protocol, hostname, and port, and whether the service only accepts traffic from IP addresses on an allowlist.
- **Some requests fail:** The service closed connections under load, during maintenance, or during a deployment on its side. Compare the timestamps of the errors with the service's logs and status page.

Other causes include:

- **Timeouts and rate limits on the service:** The service closes connections that stay open too long or that exceed its request limits.
- **TLS or protocol mismatches:** The service expects a different TLS version or protocol than the client uses.
- **IP allowlists:** Vercel Functions send requests from dynamic IP addresses by default, so a service that only allows specific addresses resets the connection. To send requests from fixed IP addresses that the service can allow, use [Static IPs](/docs/networking/static-ips), which come from a pool shared with other customers, or [Secure Compute](/docs/networking/secure-compute), which gives you dedicated IP addresses.
- **Distance from the service:** A function that runs far from the service has longer network paths and more chances for a connection to drop. Set the [function region](/docs/functions/configuring-functions/region) close to your data source.

### Diagnose the error

1. Ask the service's provider, or check its logs, to find out whether the request arrived. If it did, the service or a proxy in front of it closed the connection.

2. Find the failing requests in your [runtime logs](/docs/logs/runtime) and note the time, route, and function region of each one. With [Vercel CLI](/docs/cli/logs), you can search for the error:

   ```bash filename="terminal"
   vercel logs --environment production --query "ECONNRESET" --since 1h
   ```

3. If the logs don't show the cause, log network activity for each request. Add the `NODE_DEBUG` [environment variable](/docs/environment-variables) to the **Preview** environment, redeploy, and reproduce the error on the preview deployment. Use the value `fetch,net` for requests made with `fetch`, or `http,https,net` for requests made with the `node:http` and `node:https` modules. Remove the variable when you finish.

4. Check whether the errors start at a certain number of parallel requests. If they do, lower the number of requests the function sends at once.

> **💡 Note:** `NODE_DEBUG` output can include request headers, such as authorization
> tokens and cookies. Avoid setting it in production, and redact credentials
> before you share these logs.

### Handle connection resets in your code

A reset can still happen when everything is configured correctly, so set a timeout on outgoing requests and retry the ones that fail. This helper retries a request up to three times and waits longer before each attempt. If you pass your own `signal`, the helper cancels the request and stops retrying when that signal aborts:

```ts filename="lib/fetch-with-retry.ts"
export async function fetchWithRetry(
  url: string,
  init?: RequestInit,
  { retries = 3, timeoutMs = 5000 } = {},
): Promise<Response> {
  for (let attempt = 0; ; attempt++) {
    const timeout = AbortSignal.timeout(timeoutMs);
    const signal = init?.signal
      ? AbortSignal.any([init.signal, timeout])
      : timeout;

    try {
      return await fetch(url, { ...init, signal });
    } catch (error) {
      const code = (error as { cause?: { code?: string } }).cause?.code;
      const retryable = code === 'ECONNRESET' || timeout.aborted;

      if (init?.signal?.aborted || !retryable || attempt >= retries) {
        throw error;
      }

      await new Promise((resolve) =>
        setTimeout(resolve, Math.min(100 * 2 ** attempt, 2000)),
      );
    }
  }
}
```

> **💡 Note:** Only retry requests that are safe to repeat. A reset can arrive after the
> service has processed the request, so retrying a request that creates or
> charges for something can run it twice.

### Contact Vercel Support

If the provider confirms that it received the request and responded, but your function still logs `ECONNRESET`, [open a support case](/docs/support-center). Include the following:

- The deployment URL and the route of the function
- The time of the error in UTC and the function region
- The function's runtime and version
- The runtime logs for the failed request, with credentials redacted
- Any details the provider has about the request, such as its own request ID or logs

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
