# Motoko Canister Upgrade Error

**URL:** <https://forum.dfinity.org/t/motoko-canister-upgrade-error/43734>\
**Category:** Developers\
**Created:** [April 12, 2025, 10:13pm UTC](https://forum.dfinity.org/t/motoko-canister-upgrade-error/43734 "2025-04-12T22:13:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![successaje](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/successaje/32/7924_2.png) [@successaje](https://forum.dfinity.org/u/successaje)\
**Post date:** [April 12, 2025, 10:13pm UTC](https://forum.dfinity.org/t/motoko-canister-upgrade-error/43734/1 "2025-04-12T22:13:43Z")

</div>

Hi guys,  
I’m currently facing an issue while trying to upgrade one of my canisters (`kitchen`) and I keep running into this error:

`Error: Failed while trying to deploy canisters. Caused by: Failed while trying to deploy canisters. Failed while trying to install all canisters. Failed to install wasm module to canister 'kitchen'. Failed during wasm installation call: The replica returned a replica error: reject code CanisterError, reject message Error from Canister 6cxww-biaaa-aaaal-adebq-cai: Canister called `ic0.trap` with message: 'canister_pre_upgrade attempted with outstanding message callbacks (try stopping the canister before upgrade)' Canister Backtrace: unknown function at index 40 . Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: https://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly, error code None`

## Things I’ve Tried

- Reinstalling the code with `dfx canister install kitchen --mode upgrade`
- Confirmed `pre_upgrade()` is synchronous (no `await` or async behavior)

I use dfx version 0.16.0

For some weird reasons, it works sometimes if retried persistently.

Would appreciate any insights or guidance on this — especially from anyone who has encountered this

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [April 14, 2025, 11:57am UTC](https://forum.dfinity.org/t/motoko-canister-upgrade-error/43734/2 "2025-04-14T11:57:10Z")

</div>

Does your canister make calls to other canisters that it needs to await?

Motoko will refuse to upgrade if your canister is waiting on a response from another canister (including itself).

Try doing dfx canister stop kitchen before you do attempt the upgrade.

This should allow the canister to refuse new requests while waiting for old requests to finish processing.

Once it is in a stopped state, it should have no outstanding message callbacks and can be upgraded.

---

<div class="post-metadata">

**Author:** ![successaje](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/successaje/32/7924_2.png) [@successaje](https://forum.dfinity.org/u/successaje)\
**Post date:** [April 24, 2025, 8:57pm UTC](https://forum.dfinity.org/t/motoko-canister-upgrade-error/43734/3 "2025-04-24T20:57:20Z")

</div>

Thanks for the insight and so sorry for replying this late. I think the `dfx cansiter stop kitchen` does the job.
