0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Wranglerで account_id does not match any of your authenticated accounts が出たときの確認手順

0
Last updated at Posted at 2026-07-25

はじめに

Astroで作成した静的サイトをCloudflare Workersへデプロイし、共同管理しているドメインのサブドメインで公開しようとしました。

Astro
  ↓
Cloudflare Workers Static Assets
  ↓
site.example.com

親ドメインのexample.comは、自分用ではなく共同管理しているCloudflare Accountに所属しています。

自分もそのAccountの管理者として追加されており、Cloudflare DashboardではAccountを切り替えることで対象ドメインを確認できる状態でした。

しかし、ローカルからデプロイするとZoneを見つけられず、その後account_idを設定すると、次の警告が発生しました。

The account_id in your Wrangler configuration
does not match any of your authenticated accounts.

この記事では、今回行った確認と修正の手順をまとめます。

結論

原因は、次の3つが一致していなかったことでした。

対象ドメインが所属するAccount
=
ログイン時に選択したAccount
=
wrangler.jsoncで指定するAccount

初回ログイン時、自分用Accountだけを選択していたため、対象ドメインを持つ共同管理Accountが利用対象に含まれていませんでした。

また、最初のwrangler.jsoncではaccount_idも指定していませんでした。

次の手順で解決しました。

  1. 対象ドメインが所属するAccountを確認する
  2. wrangler whoamiで現在利用できるAccountを確認する
  3. 対象Accountがなければログインし直す
  4. wrangler.jsoncに対象AccountのIDを指定する
  5. 再度デプロイする

最初の設定

最初のwrangler.jsoncは次のようになっていました。

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "name": "example-site",
  "compatibility_date": "2026-07-12",
  "route": "site.example.com/*",

  "assets": {
    "directory": "./dist",
    "not_found_handling": "404-page"
  }
}

account_idは必須項目ではなかったため、この時点では指定していませんでした。

この状態でデプロイすると、対象のZoneを見つけられず失敗しました。

自分用Account
└─ 対象ドメインなし

共同管理Account
└─ Zone: example.com

デプロイ時に利用されていたのは自分用Accountでしたが、公開に使うexample.comは共同管理Accountに所属していました。

1. 対象ドメインが所属するAccountを確認する

Cloudflare Dashboardで対象ドメインを開き、どのAccountに所属しているかを確認します。

今回必要だったのは、自分用Accountではなく、example.comが存在する共同管理Accountでした。

自分用Account
└─ 対象ドメインなし

共同管理Account
└─ Zone: example.com

2. 現在利用できるAccountを確認する

次のコマンドを実行します。

npx wrangler whoami

修正前は、自分用Accountだけが表示されていました。

Account Name                  Account ID
自分用Account                 <自分用Account ID>

この状態では、共同管理Accountに所属するexample.comをデプロイ先として扱えません。

期待する状態は、対象の共同管理Accountも一覧に表示されることです。

Account Name                  Account ID
自分用Account                 <自分用Account ID>
共同管理Account               <共同管理Account ID>

3. 対象Accountがなければログインし直す

共同管理Accountが表示されない場合は、一度ログアウトします。

npx wrangler logout

その後、再度ログインします。

npx wrangler login

Accountの選択肢が表示されたら、対象ドメインが所属する共同管理Accountを含めます。

ログイン後、もう一度確認します。

npx wrangler whoami
Account Name                  Account ID
自分用Account                 <自分用Account ID>
共同管理Account               <共同管理Account ID>

4. account_idを指定する

wrangler.jsoncへ、対象ドメインが所属するAccountのIDを指定します。

修正後の設定は次のようになりました。

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "name": "example-site",
  "account_id": "<共同管理Account ID>",
  "compatibility_date": "2026-07-12",

  "routes": [
    {
      "pattern": "site.example.com",
      "custom_domain": true
    }
  ],

  "assets": {
    "directory": "./dist",
    "not_found_handling": "404-page"
  }
}

指定するのはZone IDではなく、対象のZoneとWorkerを管理するAccountのIDです。

共同管理Account
├─ Account ID
│  └─ wrangler.jsoncに指定
├─ Zone: example.com
└─ Worker: example-site

この状態で再度デプロイすると、正常に公開できました。

原因の整理

今回の流れは次の通りです。

1. 対象ドメインは共同管理Accountに所属していた
2. 初回ログイン時に自分用Accountだけを選択した
3. wrangler.jsoncにもaccount_idを指定していなかった
4. 自分用Accountには対象ドメインが存在しなかった
5. デプロイに失敗した
6. account_idを追加したが、
   共同管理Accountが利用対象に含まれていなかった
7. account_id does not match any of your
   authenticated accountsが発生した

最終的に、次の3つを共同管理Accountへ合わせることで解決しました。

対象ドメインが所属するAccount
=
whoamiに表示されるAccount
=
wrangler.jsoncのaccount_id

確認チェックリスト

共同管理しているCloudflare Accountへデプロイできない場合は、次を確認します。

  • 対象ドメインがどのAccountに所属しているか
  • 自分がそのAccountのMemberになっているか
  • npx wrangler whoamiに対象Accountが表示されるか
  • wrangler.jsoncaccount_idが対象AccountのIDか
  • Account IDとZone IDを取り違えていないか

補足

この記事では、デプロイエラーの確認と解決手順に絞ってまとめました。

CloudflareのUser・Account・Zoneの関係や、
Account名がメールアドレス形式だったことで混乱した経緯は、
個人ブログに詳しく書いています。

https://ruuma.yos-hina.com/blog/cloudflare-account-confusion/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?