Local dev:[wrangler:err] Error: Secret "<name>" not found

⛅️ wrangler 4.10.0
Your worker has access to the following bindings:
- Secrets Store Secrets:
- <name>: e8920c5985ce4098bfbbcbbe1797a323/INNGEST_SIGNING_KEY [simulated locally]
Your worker has access to the following bindings:
- Secrets Store Secrets:
- <name>: e8920c5985ce4098bfbbcbbe1797a323/INNGEST_SIGNING_KEY [simulated locally]
App: await env.<name>.get() Result:
[wrangler:err] Error: Secret "<name>" not found
[wrangler:err] Error: Secret "<name>" not found
How do I set local secrets?
6 Replies
darkpool
darkpool7d ago
put them in a .dev.vars file EDIT: not sure if this is right. was unaware of secrets store EDIT2: for anyone in future you can put them in .dev.vars but will need to access them just like a normal env (without get). See end of the thread
darkpool
darkpool7d ago
Cloudflare Docs
Environment variables · Cloudflare Workers docs
Environment variables are a type of binding that allow you to attach text strings or JSON values to your Worker
Pekket
Pekket6d ago
@NicoMarchildon did this work for you? I put the variable in the .dev.vars but still get the Secret "<name>" not found error.
darkpool
darkpool6d ago
@Pekket I might be incorrect that it goes in .dev.vars. I was unaware of the new secret store at the time. I plan on migrating to secrets store so will update what I end up doing I just migrated to secrets store. It works with --remote flag but I dont think you can use secrets defined in a local setup yet (like .dev.vars). I imagine it's coming because if you run npx wrangler secrets-store store create local-test you get ✘ [ERROR] Local secrets stores are automatically created for you on use. To create a Secrets Store on your account, use the --remote flag. but if you run npx wrangler secrets-store store list you get: ✘ [ERROR] This command is not supported in local mode. Use wrangler <cmd> --remote to list Secrets Stores on your account.
Pekket
Pekket5d ago
Ok thanks, for me everything is working good remotely. Locally i get the error Secret .. not found. I guess we will have to wait for an update.
darkpool
darkpool5d ago
I found a workaround. I have a boolean variable DEV so anytime I access a secret I just do:

env.DEV === "true" ? env.SECRET : await env.SECRET.get(),

env.DEV === "true" ? env.SECRET : await env.SECRET.get(),
and then put the secret in .dev.vars

Did you find this page helpful?