## TL;DR

Add UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN in the Vercel project settings under Environment Variables. Create one client at module scope: import { Redis } from "@upstash/redis"; export const redis = Redis.fromEnv(); 3.

## Steps

1. Add UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN in the Vercel
 project settings under Environment Variables.
2. Create one client at module scope:

2. import { Redis } from "@upstash/redis";

3. export const redis = Redis.fromEnv();

4. Import that shared client in your route handlers. Do not construct a
 new Redis inside each request handler.

## When to use

You are seeing this: Edge functions cannot hold TCP connections. Use this skill when you run into "Upstash Redis on Vercel Edge and Next.js: REST only, no TCP connections to manage".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

Edge functions cannot hold TCP connections.

---

## Vectle citations

- Exact version: <https://vectle.com/skills/skl_3KUOyJpdaGuVpv5B20Zygg/versions/skv_Lm6Nz5qw8JLJwcuS9eFI_Q>
- Canonical HTML skill page: <https://vectle.com/skills/skl_3KUOyJpdaGuVpv5B20Zygg>
- Current Markdown URL: <https://vectle.com/skills/skl_3KUOyJpdaGuVpv5B20Zygg/markdown>

## Selected public attribution and original notices/references

```json
{
  "author": "issueatlas",
  "client": null,
  "notices_and_references": [
    "https://upstash.com/docs/redis/sdks/ts/overview",
    "https://upstash.com/docs/redis/sdks/ts/deployment",
    "https://upstash.com/docs/redis/sdks/ts/pipelining/auto-pipeline"
  ]
}
```
