Deployment fails with 503 Service Unavailable, balance is 0 cycles and the freezing threshold 0 cycles

Hello.
I am trying to deploy a static website on IC using this tutorial.

I have set up a cycle wallet as per the instructions on how to get a cycle forset. When I run the following command, the cycle balance is displayed.

$ dfx wallet --network=ic balance

20.099 TC (trillion cycles).

In this state, when I try to deploy, I get the following error message.

$ dfx deploy --network ic --with-cycles 100000000000
Deploying all canisters.
All canisters have already been created.
Building canisters...
Building frontend...
Installing canisters...
Installing code for canister website, with canister ID mlsv7-lyaaa-aaaag-aatla-cai
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 'website'.
      Failed to install wasm in canister 'mlsv7-lyaaa-aaaag-aatla-cai'.
        Failed to install wasm.
          The replica returned an HTTP Error: Http Error: status 503 Service Unavailable, content type "application/cbor", content: Canister mlsv7-lyaaa-aaaag-aatla-cai is out of cycles: requested 1211390000 cycles but the available balance is 0 cycles and the freezing threshold 0 cycles

I do not know why it says the balance is insufficient. Can you please tell me what is the cause and what I should check or do?

Here is the file configuration and dfx file settings.

[dfx.json]

{
  "canisters": {
      "website": {
          "type": "assets",
          "source": ["dist"]
      }
  }
}

I think this is saying that your cycles wallet has a non-zero balance but the canister you’re trying to deploy to has a zero balance.

If you view your cycles wallet in a web browser as described here I think that will be the case:

It looks like you tried to deploy with 100 billion cycles, which will only cover the cost of canister creation. It seems like your canister was created and now has 0 cycles left. Maybe try topping it up from your cycles wallet by using the deposit_cycles command before trying to deploy again.

Thank you for your response!
I could see on the website that the canister was created.

However, when I used the deploy command, an error was returned, which means that the canister was created but nothing more can be done (1211390000 cycles required)?

I accessed the canister ID and got this result.

Thanks for your response!

Since I created a static website, I thought that only the canister creation cost would be sufficient for the minimum required cycles, but I guess that is not enough.

So I ran the following command to check the status of the canisters, and it returned an error, as did the deposit-cycles command.

$ dfx canister --wallet x4ih4-7iaaa-aaaag-aarya-cai  deposit-cycles 100000000000 website
Error: Failed to fetch root key.
Caused by: Failed to fetch root key.
  Encountered an error while trying to query the replica.
    An error happened during communication with the replica: error sending request for url (http://127.0.0.1:8000/api/v2/status): error trying to connect: tcp connect error: Connection refused (os error 61)

I run dfx start and the replica is up, but I get an error in the terminal.

Sep 05 02:44:57.242 INFO Executing "/Users/user/.cache/dfinity/versions/0.11.1/replica" "--replica-version" "0.8.0" "--config-file" "/Users/user/Desktop/div/ic-static-website/.dfx/state/replicated_state/ic.json5", Application: starter
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Crypto state directory /Users/user/Desktop/div/ic-static-website/.dfx/state/replicated_state/node-100/crypto has permissions 0o40755, allowing general access"', replica/src/setup.rs:297:75
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'replica-actor' panicked at 'called `Result::unwrap()` on an `Err` value: Cannot start the replica: Timeout', src/dfx/src/actors/replica.rs:371:78
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I’m investigating the error but currently have no known solution.

You need to include —network=ic if you want to perform this command on the main network.

From the log, the http://127.0.0.1:8000/api/v2/status is trying to hit localhost (which will fail unless your local dfx is deployed with that exact wallet and your canister is deployed locally as well.

1 Like

Thank you for pointing this out.
Now I understand why I need to specify the network properly!

After that,

  • That the redeployment was successful by replenishing the cycles before redeploying.
  • That by deploying the new canister with enough cycles it was deployed on IC from the beginning with no problems.

was confirmed. Thank you!

One question that remains is the behavior when an error is returned due to insufficient cycles. The canister was created with an ID assigned, but when I accessed it on the browser, I got an error message that there was no Wasm module.

I had figured this one out from the Docs cost table, but I am not quite sure what the cost was for, apart from creating the canister. Storage costs? Because I specified asset canisters in the type…? This may be because I do not properly understand what is actually happening on the IC side during deployment.

Basically, dfx does two things on initial deployment: Create a canister, and upload wasm to it. If the first step succeeds and the second fails, then you have a canister without any wasm in it, which is the initial state of every canister.

dfx canister --network ic status <canister name or id> can always tell you what’s going on with a canister (as long as you control it). By saying --with-cycles <100 B> (I don’t feel like counting zeros) it used 100B to create the canister, and now no cycles are left in the canister since you created it without any extra.

Any operation you do on a canister requires cycles - storing data, uploading new wasm modules, making update calls. And this is what your original error message says. requested 1211390000 cycles but the available balance is 0 cycles To upload your wasm, it requires 1211390000 cycles available, but you don’t have any extra.

1 Like