# Deploy an app twice on the IC (Staging env)

**URL:** <https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661>\
**Category:** Developers\
**Created:** [July 2, 2021, 4:12pm UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661 "2021-07-02T16:12:01Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [April 19, 2022, 10:27pm UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/22 "2022-04-19T22:27:53Z")

</div>

Ok…I’ve done something horribly wrong and nothing is making sense anymore. Anyone have any reason why this would work:

```auto
dfx canister --network local install canister_dev --mode=reinstall --argument '(record {owner =principal "6i6da-t3dfv-vteyg-v5agl-tpgrm-63p4y-t5nmm-gi7nl-o72zu-jd3sc-7qe"})'

```

But this right after it would not:

```auto
dfx canister --network ic install canister_dev --mode=reinstall --argument '(record {owner =principal "6i6da-t3dfv-vteyg-v5agl-tpgrm-63p4y-t5nmm-gi7nl-o72zu-jd3sc-7qe"})'

```

It returns:

Do you want to proceed? yes/No  
yes  
Reinstalling code for canister canister\_dev, with canister\_id frfol-iqaaa-aaaaj-acogq-cai  
Error: No such file or directory (os error 2)

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [April 19, 2022, 11:33pm UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/23 "2022-04-19T23:33:20Z")

</div>

To fix this I had to create different entries in my dfx.json called canister\_stage and canister\_dev. I had to make them custom and point to the wasm produced when I build canister. A bit of a hack bu the file not found error went away.

---

<div class="post-metadata">

**Author:** ![Oleksii](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/oleksii/32/25411_2.png) [@Oleksii](https://forum.dfinity.org/u/Oleksii)\
**Post date:** [April 27, 2022, 11:24am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/24 "2022-04-27T11:24:30Z")

</div>

Hi guys,

Also getting same error during deployment. I can perform all commands through “–network dev” except “install”. Is there any fix or explanation what is wrong?

“Creating UI canister on the dev network.  
Error: The replica returned an HTTP Error: Http Error: status 404 Not Found”

---

<div class="post-metadata">

**Author:** ![Litzi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/litzi/32/5558_2.png) [@Litzi](https://forum.dfinity.org/u/Litzi)\
**Post date:** [April 28, 2022, 10:09am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/25 "2022-04-28T10:09:15Z")

</div>

We’ve got this working by setting the key `__Candid_UI` on our `canister_ids.json` like so (canister\_ids are just examples!):

```auto
{
  "__Candid_UI": {
    "ic": "a2gq7-oaaaa-aaaab-qaa4q-cai",
    "YOUR_NETWORK_NAME": "a2gq7-oaaaa-aaaab-qaa4q-cai"
  },
  ...
}

```

Also important was that we set the wallet for the identity using this:

```auto
dfx identity --network dev set-wallet $(dfx identity --network ic get-wallet)

```

---

<div class="post-metadata">

**Author:** ![Oleksii](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/oleksii/32/25411_2.png) [@Oleksii](https://forum.dfinity.org/u/Oleksii)\
**Post date:** [April 28, 2022, 10:13am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/26 "2022-04-28T10:13:54Z")

</div>

Yes. Works for me. Thanks!

---

<div class="post-metadata">

**Author:** ![rem.codes](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rem.codes/32/40260_2.png) [@rem.codes](https://forum.dfinity.org/u/rem.codes)\
**Post date:** [May 16, 2022, 7:54am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/27 "2022-05-16T07:54:18Z")

</div>

I run a bash script to deploy my **backend** canisters one-by-one to the specified environment, but i am running into the issue that it tries to deploy a UI canister for every canister im trying to deploy 😕

```auto
dfx deploy --network=dev group_management_controller --no-wallet

dev > Deploying group_management_controller canister..
Deploying: group_management_controller
All canisters have already been created.
Building canisters...
Executing 'cargo build -q --target wasm32-unknown-unknown --package group_management_controller --release'
Executing 'ic-cdk-optimizer target/wasm32-unknown-unknown/release/group_management_controller.wasm -o target/wasm32-unknown-unknown/release/group_management_controller-opt.wasm'
Original: 2.77 MiB
Stripping Unused Data Segments...
    Size: 1.05 MiB (62.1% smaller)
Execute a binaryen optimization pass on your WASM....
    Size: 969.61 KiB (9.9% smaller)

Final Size: 969.61 KiB (65.8% smaller)
Installing canisters...
Creating UI canister on the dev network.
Error: The replica returned an HTTP Error: Http Error: status 404 Not Found, content type "text/html", content: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.21.3</center>
</body>
</html>

dfx deploy --network=dev management_controller --no-wallet

 dev > Deploying management_controller canister..
Deploying: management_controller
All canisters have already been created.
Building canisters...
Executing 'cargo build -q --target wasm32-unknown-unknown --package management_controller --release'
Executing 'ic-cdk-optimizer target/wasm32-unknown-unknown/release/management_controller.wasm -o target/wasm32-unknown-unknown/release/management_controller-opt.wasm'
Original: 2.53 MiB
Stripping Unused Data Segments...
    Size: 855.98 KiB (66.9% smaller)
Execute a binaryen optimization pass on your WASM....
    Size: 773.42 KiB (9.6% smaller)

Final Size: 773.42 KiB (70.1% smaller)
Installing canisters...
Creating UI canister on the dev network.
Error: The replica returned an HTTP Error: Http Error: status 404 Not Found, content type "text/html", content: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.21.3</center>
</body>
</html>

etc..

```

---

<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:** [May 16, 2022, 8:00am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/28 "2022-05-16T08:00:23Z")

</div>

@rem.codes would you mind sharing how you define the ‘dev’ network? [The code](https://github.com/dfinity/sdk/blob/master/src/dfx/src/lib/operations/canister/install_canister.rs#L40-L42) is quite clear that the UI canister should only be deployed if the network is NOT the real IC. I suspect the problem is either with a) how the network is specified or b) how we determine if it’s the real IC or not.

---

<div class="post-metadata">

**Author:** ![rem.codes](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rem.codes/32/40260_2.png) [@rem.codes](https://forum.dfinity.org/u/rem.codes)\
**Post date:** [May 16, 2022, 8:03am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/29 "2022-05-16T08:03:34Z")

</div>

Thanks for the quick response, my `dfx.json` has this

```auto
"networks": {
    "dev": {
      "providers": [
        "https://ic0.app/"
      ],
      "type": "persistent"
    }
  }

```

---

<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:** [May 16, 2022, 8:10am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/30 "2022-05-16T08:10:28Z")

</div>

Remove the trailing slash in the provider and it will recognise it as a real IC network. I’ll make a PR that fixes this.

---

<div class="post-metadata">

**Author:** ![rem.codes](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rem.codes/32/40260_2.png) [@rem.codes](https://forum.dfinity.org/u/rem.codes)\
**Post date:** [May 16, 2022, 8:11am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/31 "2022-05-16T08:11:57Z")

</div>

Awesome, this fixed it! Thanks 🦸

---

<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:** [May 22, 2022, 6:35pm UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/32 "2022-05-22T18:35:48Z")

</div>

Dumb question, but everyone who is deploying canisters to staging (which simply points to the IC mainnet) is still paying cycles to do so, right?

---

<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:** [May 23, 2022, 6:47am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/33 "2022-05-23T06:47:19Z")

</div>

Yes, there’s no way around paying cycles for that.

---

<div class="post-metadata">

**Author:** ![d3w3](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/d3w3/32/4280_2.png) [@d3w3](https://forum.dfinity.org/u/d3w3)\
**Post date:** [July 5, 2022, 8:51pm UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/34 "2022-07-05T20:51:04Z")

</div>

Ok, now everybody is able to get a staging environment up and running, but what strategies do you apply in order to differentiate staging from production and also let [Kinic](https://74iy7-xqaaa-aaaaf-qagra-cai.raw.ic0.app/search/Supernova) our new search engine know?

---

<div class="post-metadata">

**Author:** ![ilbert](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ilbert/32/8717_2.png) [@ilbert](https://forum.dfinity.org/u/ilbert)\
**Post date:** [February 14, 2025, 12:09pm UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/35 "2025-02-14T12:09:01Z")

</div>

I’m still facing some of the issues that people have raised in this thread.

# Context

I’m using the [Cycles ledger](https://internetcomputer.org/docs/current/developer-docs/defi/cycles/cycles-ledger) to manage my cycles.  
I have deployed two canisters, named `backend` and `frontend`, a while ago on mainnet.  
Now, I want to deploy the same canisters as “staging” to test out some new features before shipping them to the already existing “production” canisters.

# Problem

Here are the steps I made to create a staging deployment environment next to the already existing production environment:

1. Temporarily removed the `canister_ids.json` file
2. Deployed my two canisters as if they were new mainnet canisters with the following command:

```bash
dfx deploy --ic --no-wallet

```

3. Added the “old” production canisters again to the newly created `canister_ids.json` file, and renamed the new canister network keys from `ic` to `staging`. Here’s the `canister_ids.json` updated file:

```json
{
    "backend": {
        "staging": "<canister-id-just-created>",
        "ic": "<canister-id-already-existing>"
    },
    "frontend": {
        "staging": "<canister-id-just-created>",
        "ic": "<canister-id-already-existing>"
    }
}

```

4. Added the `staging` network to the `dfx.json` file:

```json
{
    "canisters": {
        "backend": {...},
        "frontend": {...}
    },
    "networks": {
        ...
        "staging": {
            "providers": ["https://icp-api.io"],
            "type": "persistent"
        }
    }
}

```

5. Deployed both canisters again using the following command:

```bash
dfx deploy --network staging --no-wallet

```

6. Got the error:

```bash
Installing canisters...
Creating UI canister on the staging network.
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to install all canisters.
Caused by: Failed to install wasm module to canister 'backend'.
Caused by: Failed to install candid UI canister.
Caused by: Create canister call failed.
Caused by: The replica returned a rejection error: reject code CanisterReject, reject message Caller <my-principal> is not allowed to call ic00 method provisional_create_canister_with_cycles, error code Some("IC0406")

```

# Workaround

The workaround found by @Litzi seems to work for me as well:

> [@Litzi](#):
>
> We’ve got this working by setting the key `__Candid_UI` on our `canister_ids.json` like so (canister\_ids are just examples!):
> 
> ```auto
> {
> "__Candid_UI": {
> "ic": "a2gq7-oaaaa-aaaab-qaa4q-cai",
> "YOUR_NETWORK_NAME": "a2gq7-oaaaa-aaaab-qaa4q-cai"
> },
> ...
> }
> 
> ```

With one small difference: the Candid UI mainnet canister id is now `a4gq6-oaaaa-aaaab-qaa4q-cai`.

---

<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:** [February 17, 2025, 11:57am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/36 "2025-02-17T11:57:16Z")

</div>

> [@ilbert](#):
>
> `"providers": ["https://icp-api.io"],`

Change this to `"providers": ["https://icp0.io"],` and you should be good to go. dfx’s logic to detect mainnet is too simplistic and it currently only accepts this one domain. I’ll see if we can improve that

---

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [August 4, 2025, 8:19am UTC](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661/37 "2025-08-04T08:19:44Z")

</div>

Like always, @ilbert got the best answers.  
but,  
Is there a stupid-people-friendly GitHub example?

[Previous page](https://forum.dfinity.org/t/deploy-an-app-twice-on-the-ic-staging-env/5661.md?page=1)
