How do I upgrade an application previously deployed on the Internet Computer? How do I reinstall or re-deploy a canister smart contract?

To upgrade/re-deploy a canister smart contract on the Internet Computer blockchain mainnet:

  1. Open a new terminal and navigate to your project directory.
  2. Start the Internet Computer network, if necessary.

    In most cases, this step is only necessary if you are running the Internet Computer network locally.

    If you were upgrading canisters on a remote network, you would include the --network command-line option to perform tasks on that network.
  3. Verify you have canister identifiers for all of the canisters you want to upgrade.

    Note that your program must identify the variables for which to maintain state by using the stable keyword in the variable declaration.

    For more information about declaring stable variables, see the Motoko Programming Language Guide.
  4. Upgrade all of the canisters by running the following command:

    dfx canister install --all --mode upgrade



A local upgrade requires similar steps:

  1. Open a new terminal and navigate to your project directory.
  2. Verify you have canister identifiers for all of the canisters you want to upgrade.
  3. Upgrade all of the canisters by running the following command:

    dfx canister install --all --mode upgrade


To view in-depth information about upgrading and reinstalling canisters, please check out the Internet Computer Docs.

You can also learn more about canisters on the Internet Computer Wiki.

Updated