# 400 error: unknown\_domain, can't connect to canister in IC network from local project

**URL:** <https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269>\
**Category:** Developers\
**Created:** [September 18, 2024, 8:49am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269 "2024-09-18T08:49:40Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 18, 2024, 8:49am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/1 "2024-09-18T08:49:41Z")

</div>

In the last week and before, I have never seen this error reported.  
I’m connecting to the IC network through my local project (localhost:3000) and it generates the error: AgentHTTPResponseError: Server returned an error.  
Code: 400 (Bad Request)  
Body: unknown\_domain  
After testing on multiple computers, this does not appear to be a problem with my personal computer.  
But I don’t know exactly what’s wrong, since I haven’t changed the code about the API recently.

---

<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:** [September 18, 2024, 9:02am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/2 "2024-09-18T09:02:28Z")

</div>

What dfx version is this and did you update dfx recently?

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 18, 2024, 9:10am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/3 "2024-09-18T09:10:06Z")

</div>

dfx 0.17.0, no dfx updates.  
We’ve tried rolling back the did multiple times, and this problem occurs after rolling it back

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 18, 2024, 9:21am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/4 "2024-09-18T09:21:15Z")

</div>

We recently renewed our domain name once, but the issue only occurs locally, the online environment is working fine

---

<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:** [September 18, 2024, 9:23am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/5 "2024-09-18T09:23:21Z")

</div>

Does the issue disappear if you use `127.0.0.1` instead of `localhost`?

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 18, 2024, 9:31am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/6 "2024-09-18T09:31:14Z")

</div>

This problem does not occur, but it is not possible to call II, and the initialization of the authorization leads to a direct error:

```auto
index.ts:34 beforeEnter Err: Error: Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https:// developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto
    at _getEffectiveCrypto (chunk-CZQH26SK.js?v=35fbe591:2594:11)
    at _ECDSAKeyIdentity.generate (chunk-CZQH26SK.js?v=35fbe591:2616:29)
    at AuthClient.create (chunk-CZQH26SK.js?v=35fbe591:3455:38)
    at async initAuth (auth.ts:32:14)
    at async beforeEnter (index.ts:27:20)

```

Here are our dependency versions

```auto
    “@dfinity/agent”:“^0.19.3”,
    “@dfinity/auth-client“:”^0.19.3”,
    “@dfinity/candid“:”^0.19.3”,
    “@dfinity/identity“:”^0.19.3”,

```

---

<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:** [September 18, 2024, 9:36am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/7 "2024-09-18T09:36:39Z")

</div>

You are on pretty old versions of the `@dfinity/` dependencies and dfx is old-ish as well. Is there a chance that you could update? I’m pretty sure that would fix most of your issues

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 18, 2024, 11:48am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/8 "2024-09-18T11:48:48Z")

</div>

I’ve updated the dependency version to the latest, haven’t updated dfx yet, and it still shows the 400 unknown domain error.

```auto
    "@dfinity/agent": "^2.1.1",
    "@dfinity/principal": "^2.1.1",
    "@dfinity/auth-client": "^2.1.1",
    "@dfinity/candid": "^2.1.1",

```

I’ll try to update dfx next

---

<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:** [September 18, 2024, 11:56am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/9 "2024-09-18T11:56:05Z")

</div>

👍 just don’t forget to `dfx stop` and `dfx start` after the upgrade, otherwise you won’t notice a difference from upgrading dfx

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 18, 2024, 12:05pm UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/10 "2024-09-18T12:05:42Z")

</div>

No, I didn’t start dfx locally, I connected to the canister in the IC environment in my local front-end project

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 19, 2024, 4:18am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/11 "2024-09-19T04:18:08Z")

</div>

Hi, I updated the dfx and still find errors.  
I need to emphasize that I’m using a local frontend project connected to a canister in the IC network.  
Not a copy of the local dfx build used.  
This setup was working until last week and I could test it locally online, but since yesterday it suddenly doesn’t work.

---

<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:** [September 19, 2024, 6:59am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/12 "2024-09-19T06:59:40Z")

</div>

I’m out of ideas. @anon74414410 do you maybe have an idea?

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 19, 2024, 7:40am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/13 "2024-09-19T07:40:13Z")

</div>

I tried a number of things including: testing with multiple computers, rolling back code, updating dependencies, and looking at recently modified code.  
Now I have a breakthrough.  
I just changed the canister id pointing to the backend to change the id to a different canister, but it still reports an error 400 unknown\_domain.  
I’m guessing there might be a problem with the step that initiates the api request.  
And I’m wondering if there have been any recent updates to @dfinity/agent in this regard?

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 19, 2024, 9:01am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/14 "2024-09-19T09:01:56Z")

</div>

🥶 I’ve solved the problem, which was as follows: foundation’s api url was migrated and my local forwarding url wasn’t updated, causing the forwarding to fail

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/3/8/38eb72c144e4b45c9da094c0aca608d9787c81dd.png)  
After changing the URL to the latest [https://icp-api.io](https://icp-api.io), the local project is running normally.

---

<div class="post-metadata">

**Author:** ![e274426380](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/e274426380/32/2555_2.png) [@e274426380](https://forum.dfinity.org/u/e274426380)\
**Post date:** [September 19, 2024, 9:11am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/15 "2024-09-19T09:11:43Z")

</div>

I would like to know where I can subscribe to the Foundation’s api URL to prevent this from happening again.  
👿This bug has been killing me for the past 2 days.

---

<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:** [September 19, 2024, 9:22am UTC](https://forum.dfinity.org/t/400-error-unknown-domain-cant-connect-to-canister-in-ic-network-from-local-project/35269/16 "2024-09-19T09:22:40Z")

</div>

The domain change was triggered by [this incident](https://forum.dfinity.org/t/important-community-update-on-ic0-app-domain-being-flagged-by-an-anti-spam-blocklist/18537). We hope it won’t happen again, but if it would, the changes would be announced first here on the forum
