Why does wrangler default to production?

For Workers & Pages, what is the name of the domain?

n/a

What is the error number?

n/a

What is the error message?

n/a

What is the issue or error you’re encountering

I noticed that npx wrangler d1 commands default to production. For example if I run npx wrangler d1 create test-db on my local macbook pro terminal, it creates the table in my production CF account. I find it hard to believe that cloudflare would allow this, so my default assumption is I must be doing something wrong. Why does running that command default to production instead of local?

What version of wrangler are you using? And which commands specifically?

Most D1 commands default to --local, and require you to add --remote to execute on the Cloudflare-hosted database.

2 Likes

Hi @cherryjimbo and thank you for your response.
Here’s a screen recording where you can see:

  1. The command I’m running: npx wrangler d1 create test-db
  2. Proof that it defaults to production
  3. Doesn’t recognize the “–local” flag

What am I doing wrong?

I appreciate your help, Thanks

wrangler d1 create does target remote, because there’s not really a concept of “creating” DBs locally. They’ll be created when you spin up the local dev server in your .wrangler folder if you have them in your wrangler config.

execute, export, etc. do target local first though.

1 Like

Ah makes sense, thanks for explaining.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.