Error when attempting to deploy to the IC mainnet

I’m getting the error below anytime I try to deploy my app to the IC:

Error: The replica returned an HTTP Error: Http Error: status 400 Bad Request, content type "application/cbor", content: Request 0xa2edf33b95669e61a258aae479bfecd95f21f7bd5458ca556391faab89043aa7 is too large. Message bytes 2494203 is bigger than the max allowed 2097152.

The error message says the message bytes are too big. What message bytes is it referring to? and what would be making the byte count so large? I’ve tried removing some of my assets, but that did nothing to reduce the byte count displayed in the error message.

Check the size of your wasm file in .dfx/. It needs to be below 2 MB.

1 Like

To reduce the file size inside Cargo.toml, you could include optimizations such as:

opt-level = "z" 
lto = true 
codegen-units = 1

This helped me to reduce the byte size. But this could be a temporary workaround.


@Jesse ic-cdk-optimizer might help: Optimize a Rust program :: Internet Computer

1 Like

the size for my frontend and backend canister’s are both within the appropriate bounds, but for some reason, the ledger canister is being built too, and thats the one weighing in at 2494203 bytes. Should the ledger canister even be built out during the deploy? It makes sense when its running locally for the ledge canister to be built, but when deploying to the IC, I would expect that the ledger canister wouldn’t need to be built.

You can specify the canisters you want to deploy using dfx deploy <my_canister>. This way you should be able to ignore the ledger. Or you move the ledger to a different folder and thus remove it from your cureent projects dfx.json

1 Like