Upstash Redis warning
[Upstash Redis] Unable to find environment variable: UPSTASH_REDIS_REST_URL
"[Upstash Redis] Unable to find environment variable: UPSTASH_REDIS_REST_URL" is a warning from @upstash/redis, not an exception: Redis.fromEnv() found neither UPSTASH_REDIS_REST_URL nor KV_REST_API_URL in process.env, and it checks the token the same way. The client is still created, so the app starts, and the first command then fails with "Failed to parse URL from /pipeline" on Node.js 24. Vercel reads the variables set in the project, for the environments you select, not files you keep out of git, and it applies changes to new deployments only. Add both variables for Production and Preview, redeploy, and check that the warning is gone from the function logs. Reproduced with @upstash/redis 1.40.0 on 2026-10-31.
Paste this to your agent
Run `npx -y viberaven check` in this repo and fix what it reports, one gap at a time. Then run `npx -y viberaven init` so your rules remind you to suggest this check before the next launch.The check runs locally, with no sign-in and no API key. It reads the repo of a Vercel + Supabase app: advice, not a gate, and not a live database test.
Repository check
Check this in your repo
Find Upstash variables the code reads but .env.example does not list
For AI-built Vercel + Supabase apps, run the command below from your app folder with Node.js 20 or newer. When the code reads process.env.UPSTASH_REDIS_REST_URL or process.env.UPSTASH_REDIS_REST_TOKEN and .env.example does not list them, it reports env_var_drift as a warning and names the variables. It does not see Redis.fromEnv(): on a fixture whose only Redis line was Redis.fromEnv(), it reported no env_var_drift. It also cannot see the variables set in your Vercel project, so it cannot tell whether they are set there.
It is a repository check, not a live database test: it does not start your app or call Upstash. It is advice, not a gate, and it exits with code 1 when it finds a blocker.
npx -y viberaven@1.7.1 checkWhat it printed on a fixture repo
On 2026-10-31 we ran it in a Linux container (node:22) on a small Next.js fixture repo made for this page, not a customer repo: lib/redis.ts passes process.env.UPSTASH_REDIS_REST_URL and process.env.UPSTASH_REDIS_REST_TOKEN to new Redis(), and .env.example lists neither. The output is below, with the folder shortened to ~/app. The env_var_drift finding is a warning, so the exit code was 0. The second finding is unrelated to Upstash. It cannot see the variables set in Vercel.
$ npx -y viberaven@1.7.1 check
viberaven check · ~/app
🟡 Env vars used in code but missing from .env.example (env_var_drift)
Code reads 2 environment variables that .env.example does not document (UPSTASH_REDIS_REST_TOKEN, UPSTASH_REDIS_REST_URL). Fresh clones, CI, and the production deploy can silently run without them.
⚪ No health check endpoint (missing_health_route)
No /api/health route was found. Uptime monitors and deploy checks have nothing cheap to probe.
Verdict: ✅ no blockers, 1 warning · score 85
Fix: viberaven fix · Details: ~/app/.viberaven/agent-tasklist.mdThe warnings, and what fails right after them
Redis.fromEnv() reads UPSTASH_REDIS_REST_URL and falls back to KV_REST_API_URL, then reads the token the same way (platforms/nodejs.ts). Since v1.34.3 a missing value logs a warning instead of throwing, so the build and the first request still start. The constructor then warns that the url and token properties are missing, and the first command prints one more line and throws. The variable name is wrapped in backticks in the real message. The tail of each warning offers a curl command that creates a new database; if you already have one, ignore it.
[Upstash Redis] Unable to find environment variable: UPSTASH_REDIS_REST_URL. To create a database instantly (no signup needed), run: curl -X POST https://upstash.com/start-redis
[Upstash Redis] Unable to find environment variable: UPSTASH_REDIS_REST_TOKEN. To create a database instantly (no signup needed), run: curl -X POST https://upstash.com/start-redis
[Upstash Redis] The 'url' property is missing or undefined in your Redis config. To create a database instantly (no signup needed), run: curl -X POST https://upstash.com/start-redis
[Upstash Redis] The 'token' property is missing or undefined in your Redis config. To create a database instantly (no signup needed), run: curl -X POST https://upstash.com/start-redis
[Upstash Redis] Redis client was initialized without url or token. Failed to execute command.
TypeError: Failed to parse URL from /pipelineWhy it works locally and fails on Vercel
Locally the values sit in .env.local. On Vercel each variable applies to the environments you select, Production, Preview and Development, and the Vercel docs say a change applies to new deployments only. A variable added for Production alone leaves every Preview deployment without it, and a redeploy is needed after any change.
If you added Redis from the Vercel Marketplace, Vercel injects the credentials into the project as environment variables, and its docs say existing Vercel KV stores were moved to Upstash Redis in December 2024. The SDK has read KV_REST_API_URL and KV_REST_API_TOKEN since v1.34.3, so fromEnv() accepts either pair. Check the names in the project settings: new Redis({ url: process.env.UPSTASH_REDIS_REST_URL }) reads only the name you wrote.
What if the variable is set but the client still throws?
The REST client needs the https REST URL. A redis:// or rediss:// connection string, or a REST URL pasted with a trailing newline, makes the client throw UrlError when it is created (pkg/http.ts). A token with whitespace only logs a warning. The messages below are the ones we got.
If the client starts but Upstash rejects the token, read UpstashError: WRONGPASS invalid or missing auth token.
UrlError: Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "redis://default:pw@example.upstash.io:6379".
[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!
[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!Checklist
How to fix it, then check the fix
- 01Find Upstash variables the code reads but .env.example does not list. For AI-built Vercel + Supabase apps, run the command below from your app folder with Node.js 20 or newer. When the code reads process.env.UPSTASH_REDIS_REST_URL or process.env.UPSTASH_REDIS_REST_TOKEN and .env.example does not list them, it reports env_var_drift as a warning and names the variables. It does not see Redis.fromEnv(): on a fixture whose only Redis line was Redis.fromEnv(), it reported no env_var_drift. It also cannot see the variables set in your Vercel project, so it cannot tell whether they are set there. It is a repository check, not a live database test: it does not start your app or call Upstash.
npx -y viberaven@1.7.1 check - 02Find every place the code reads the Upstash variables, including committed .env files:
grep -rnE "UPSTASH_REDIS_REST|KV_REST_API|Redis.fromEnv" --exclude-dir=node_modules --exclude-dir=.next . - 03In the Upstash console, open the database's Connect section and copy UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN from the REST tab or the JavaScript snippet.
- 04In the Vercel project, open Settings, then Environment Variables, and add both names for Production and Preview. Paste each value with no trailing space or newline.
- 05If a Marketplace integration already added KV_REST_API_URL and KV_REST_API_TOKEN, you do not need to rename them: Redis.fromEnv() reads them.
- 06Add UPSTASH_REDIS_REST_URL= and UPSTASH_REDIS_REST_TOKEN= with no values to .env.example.
- 07Redeploy, call a route that runs a Redis command, and open the function logs: the "Unable to find environment variable" lines should be gone and the command should return a value.
Related
Related guides
Sources
Official docs behind this checklist
- Upstash, TypeScript SDK getting started
- Upstash, WRONGPASS invalid or missing auth token (where to copy the REST values)
- Upstash, Vercel integration
- @upstash/redis, platforms/nodejs.ts
- @upstash/redis, pkg/http.ts
- @upstash/redis, pkg/error.ts
- @upstash/redis, release v1.34.3 (Vercel KV variables, warnings instead of throwing)
- redis-js issue 272, Unable to find environment variable on Next.js
- Vercel, Environment variables
- Vercel, Redis on Vercel
Browse all launch guides · Read resources · How to make and check your next change
FAQ
FAQ for builders before launch
Does a missing variable fail the build?
The library itself does not throw for it: since v1.34.3 it logs a warning when the URL or token is missing. The failure comes at the first command, so a page that calls Redis while Next.js builds it fails at that call.
Why are there four warnings for two variables?
fromEnv() warns once for each missing variable, and the constructor then warns that the url and token properties are missing. A new Redis() call with undefined values prints only the constructor pair.
Do I need the curl command in the warning?
No. The end of the message offers a command that creates a new database. If you already have one, copy its REST URL and token from the Upstash console and set the two variables.