{"slug": "wrangler-dev-remote-silently-writes-to-your-production-kv-namespace-here-s-the", "title": "`wrangler dev --remote` silently writes to your production KV namespace — here's the fix", "summary": "A developer lost production data after using `wrangler dev --remote` without a `preview_id` field in `wrangler.toml`, causing KV writes to hit the production namespace. The fix is to add a `preview_id` pointing to a separate dev namespace. The developer also warns that remote KV is eventually consistent, unlike local simulation, and that write rates above ~1,000/minute trigger 429 errors.", "body_md": "I lost production data on a Tuesday afternoon because `wrangler.toml`\n\nhad one missing field. Not a code bug. Not a logic error. A missing `preview_id`\n\n.\n\nBy default, `wrangler dev`\n\nuses a local SQLite simulation — safe, isolated, zero real traffic. The moment you add `--remote`\n\n, every KV read and write goes to the actual Cloudflare namespace over the API. If your `wrangler.toml`\n\nonly has the `id`\n\nfield pointing at your production namespace, those writes land in prod. No warning. No confirmation prompt. Just silent data mutation on the namespace your live users depend on.\n\nThe fix is a single extra field:\n\n```\n[[kv_namespaces]]\nbinding = \"MY_STORE\"\nid = \"PROD_NAMESPACE_ID_HERE\"\npreview_id = \"DEV_NAMESPACE_ID_HERE\"\n```\n\nWrangler automatically routes `--remote`\n\ntraffic through `preview_id`\n\ninstead of `id`\n\n. Create a separate dev namespace with `wrangler kv namespace create \"MY_STORE_dev\"`\n\n, drop its ID into `preview_id`\n\n, and your production namespace is untouched. This should probably be in the quickstart docs. It isn't, at least not prominently.\n\nThe second thing worth knowing: `--remote`\n\nexposes a behavioral gap that local simulation hides entirely. Local KV is synchronous and in-process — a `put()`\n\nfollowed by a `get()`\n\non the same key always returns the fresh value. Remote KV is eventually consistent. I had a rate-limiting worker that looked completely broken under `--remote`\n\n: I'd write a counter, immediately read it back, and get the old value. The worker was correct. The local simulation had been lying to me about how production actually behaves. Switching to `--remote`\n\n(against a dev namespace, not prod) surfaced the real race condition. That's uncomfortable, but it's accurate.\n\nThere's also a write-rate ceiling worth knowing before you run any kind of seed script: hit roughly 1,000 writes/minute and you'll start seeing `429 Too Many Requests`\n\nwith error code `10013`\n\n. A 70ms sleep between writes keeps you under the limit without dramatically slowing a seed operation down.\n\nI wrote up the full breakdown — including the `wrangler tail`\n\nJSON truncation trap that cost me two hours, a shell script for seeding a dev namespace with representative data, and the exact `cacheTtl: 0`\n\npattern for honest read behavior — over on dailymanuallab.com.", "url": "https://wpnews.pro/news/wrangler-dev-remote-silently-writes-to-your-production-kv-namespace-here-s-the", "canonical_source": "https://dev.to/riversea/wrangler-dev-remote-silently-writes-to-your-production-kv-namespace-heres-the-fix-2c6p", "published_at": "2026-07-01 01:08:50+00:00", "updated_at": "2026-07-01 01:48:52.781943+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure"], "entities": ["Cloudflare", "Wrangler", "KV"], "alternates": {"html": "https://wpnews.pro/news/wrangler-dev-remote-silently-writes-to-your-production-kv-namespace-here-s-the", "markdown": "https://wpnews.pro/news/wrangler-dev-remote-silently-writes-to-your-production-kv-namespace-here-s-the.md", "text": "https://wpnews.pro/news/wrangler-dev-remote-silently-writes-to-your-production-kv-namespace-here-s-the.txt", "jsonld": "https://wpnews.pro/news/wrangler-dev-remote-silently-writes-to-your-production-kv-namespace-here-s-the.jsonld"}}