# Assistance Required: Backend-Frontend Connection Error - subnet\_not\_found

**URL:** <https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752>\
**Category:** Motoko\
**Created:** [November 17, 2023, 7:32am UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752 "2023-11-17T07:32:46Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [December 1, 2023, 4:34pm UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752/21 "2023-12-01T16:34:10Z")

</div>

Alright, solved. So the issue `subnet_not_found` error was thrown because I was (unexpectedly) performing a call against mainnet while my identity was generated and meant for the local replica.

---

<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:** [January 16, 2024, 8:02am UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752/22 "2024-01-16T08:02:07Z")

</div>

I am facing the same issue but even without my frontend canister still facing it when I try to open the `CANDID UI` I tried this [Dfx WARN: You seem to be running an outdated version of dfx. But I have latest version installed 0.12.1 - #10 by Severin](https://forum.dfinity.org/t/dfx-warn-you-seem-to-be-running-an-outdated-version-of-dfx-but-i-have-latest-version-installed-0-12-1/18554/10) nothgin was working I also tried using node16  
info

- dfx 0.15.3
- macos m1
- node v20.10.0
- cargo 1.77.0-nightly (84976cd69 2024-01-12)
- rustup 1.26.0 (5af9b9484 2023-04-05)  
This is the version for the rustup toolchain manager, not the rustc compiler.  
The currently active `rustc` version is `rustc 1.77.0-nightly (714b29a17 2024-01-15)`

---

<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:** [January 17, 2024, 9:59am UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752/23 "2024-01-17T09:59:48Z")

</div>

That sounds very weird… is it possible that your dfx.json pins an older dfx version? What is the output of `dfx start --clean -vv`?

---

<div class="post-metadata">

**Author:** ![marcpp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/marcpp/32/14921_2.png) [@marcpp](https://forum.dfinity.org/u/marcpp)\
**Post date:** [June 13, 2024, 7:54pm UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752/25 "2024-06-13T19:54:29Z")

</div>

Hey David,

I’m running into the same issue (400 subnet\_not\_found) while using the [approve](https://www.npmjs.com/package/@dfinity/ledger-icrc#gear-approve) method of the ledger-icrc library.

> [@peterparker](#):
>
> the issue `subnet_not_found` error was thrown because I was (unexpectedly) performing a call against mainnet while my identity was generated and meant for the local replica.

I feel like I could be doing the same mistake without knowing it. Here’s my code:

```auto
import { IcrcLedgerCanister } from "@dfinity/ledger-icrc";

...

export default function Profile() {
    const { actor } = useActor();

    ...

    const { approve } = IcrcLedgerCanister.create({
        actor,
        canisterId: process.env.CANISTER_ID_ICP_LEDGER,
    });

    let approveArgs = {
          spender: {
              owner : Principal.fromText(principal),
              subaccount: []
          },
          amount: 1000000000000,
          expected_allowance: 100000000,
          fee: 10000
      }

      const data = await approve(approveArgs);
      console.log("data");

```

(`process.env.CANISTER_ID_ICP_LEDGER` outputs bkyz2-fmaaa-aaaaa-qaaaq-cai, my local icp ledger canister)

Am I missing a something?

Cheers!

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [June 14, 2024, 4:50am UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752/26 "2024-06-14T04:50:24Z")

</div>

```auto
const { actor } = useActor();

    ...

    const { approve } = IcrcLedgerCanister.create({
        actor,
        canisterId: process.env.CANISTER_ID_ICP_LEDGER,
    });

```

Not sure what `actor` is, but that’s not a valid parameter here. On the contrary, you could pass an `agent` to create an `IcrcLedgerCanister` object. If you don’t, it falls back to an agent for mainnet. I am guessing that’s the reason why you get the error mentioned in this thread.

---

<div class="post-metadata">

**Author:** ![marcpp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/marcpp/32/14921_2.png) [@marcpp](https://forum.dfinity.org/u/marcpp)\
**Post date:** [June 14, 2024, 7:42am UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752/27 "2024-06-14T07:42:35Z")

</div>

`actor` is basically my canister (I’m using [ic-use-actor](https://www.npmjs.com/package/ic-use-actor) library).

Using an `agent` like so…

```auto
const agent = await createAgent({
    identity,
    //host: HOST,
});

const { approve } = IcrcLedgerCanister.create({
    agent,
    canisterId: process.env.CANISTER_ID_ICP_LEDGER,
});

let approveArgs = {
    spender: {
        owner : Principal.fromText(principal),
        subaccount: []
    },
    amount: 1000000000000,
    expected_allowance: 100000000,
    fee: 10000
}

const data = await approve(approveArgs);
console.log(data);

```

…I’m gettting a `Invalid certificate: Signature verification` failed error. Any idea how to solve this one? (I was getting this error a few days ago - [see here](https://forum.dfinity.org/t/invalid-certificate-signature-verification-failed-when-using-dfinity-ledger-icrc/31159/5) - this is why I tried to get creative and tried using `actor`)

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [June 14, 2024, 9:53am UTC](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752/28 "2024-06-14T09:53:37Z")

</div>

```auto
const agent = await createAgent({
    identity,
    //host: HOST,
});

```

If you want to develop locally, you should create an agent that fetches `fetchRootKey`. You might also need to adjust `host` even though I guess you are using dfx and also guessing that agent-js default value is tailored for it but, not sure. I always set the value locally.

[Previous page](https://forum.dfinity.org/t/assistance-required-backend-frontend-connection-error-subnet-not-found/24752.md?page=1)
