# How to regain control of a canister?

**URL:** <https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126>\
**Category:** Developers\
**Created:** [July 2, 2022, 3:48am UTC](https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126 "2022-07-02T03:48:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [July 2, 2022, 3:48am UTC](https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126/1 "2022-07-02T03:48:37Z")

</div>

This sounds ridiculous, but I accidentally removed my dfx principal as a controller of one of my canisters.

I meant to run:

```auto
dfx canister --network=ic update-settings --add-controller <principal-id>

```

but instead ran:

```auto
dfx canister --network=ic update-settings --controller <principal-id>

```

Is there any hope of retrieving my canister?

---

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [July 2, 2022, 4:10pm UTC](https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126/2 "2022-07-02T16:10:42Z")

</div>

@Vivienne

`—add-controller` and `—controller` are just so close that it’s easy to make this mistake.

Sounds like we need a dfx warning built in for the `—controller` flag. That plus or a redesign of this flag, or even maybe a `—force` flag for certain irrecoverable actions.

@jzxchiang Do you own the principal you gave access to in any way? If so you can re-add the controller on the canister you lost through that principal using the ic management canister’s `update_settings` method.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [July 4, 2022, 7:27am UTC](https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126/3 "2022-07-04T07:27:21Z")

</div>

> [@jzxchiang](#):
>
> Is there any hope of retrieving my canister?

Unless you somehow have access to the accidentally-set principal, no. As @icme described, you’d have to proxy the `update_settings` command through that principal.

> [@icme](#):
>
> `—add-controller` and `—controller` are just so close that it’s easy to make this mistake.
> 
> Sounds like we need a dfx warning built in for the `—controller` flag. That plus or a redesign of this flag, or even maybe a `—force` flag for certain irrecoverable actions.

Agreed, this is easy to confuse. I added a note to our backlog. Don’t expect any instant fixes, but it’ll happen sometime in the near-ish future.

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [July 4, 2022, 5:53pm UTC](https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126/4 "2022-07-04T17:53:34Z")

</div>

I do have access to that principal but only through Internet Identity.

Is there a way to add controllers using a principal you own via II?

---

<div class="post-metadata">

**Author:** ![Maxfinity](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/maxfinity/32/1484_2.png) [@Maxfinity](https://forum.dfinity.org/u/Maxfinity)\
**Post date:** [July 4, 2022, 11:34pm UTC](https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126/5 "2022-07-04T23:34:03Z")

</div>

Should be possible, just connect II to whatever site through agent js, and then add controllers by calling the management canister.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [July 5, 2022, 8:19am UTC](https://forum.dfinity.org/t/how-to-regain-control-of-a-canister/14126/6 "2022-07-05T08:19:59Z")

</div>

> [@jzxchiang](#):
>
> I do have access to that principal but only through Internet Identity.
> 
> Is there a way to add controllers using a principal you own via II?

I suppose it depends on how exactly you have access through II. Since II generates a new pseudonymous principal for every separate url that requests login through II, it may be more or less difficult to do. If you’re in a random page, you should be able to do the calls through agent-js as Max describes. If you added the NNS principal, you should be able to manually add the canister to the canister list and add your normal principal through there.
