# Node fetch to replica connection refused

**URL:** <https://forum.dfinity.org/t/node-fetch-to-replica-connection-refused/26958>\
**Category:** Developers\
**Created:** [January 25, 2024, 1:11am UTC](https://forum.dfinity.org/t/node-fetch-to-replica-connection-refused/26958 "2024-01-25T01:11:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [January 25, 2024, 1:11am UTC](https://forum.dfinity.org/t/node-fetch-to-replica-connection-refused/26958/1 "2024-01-25T01:11:43Z")

</div>

I want to perform http requests into my local canister. With curl from the command line everything works just fine:

```auto
curl http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/res-send

```

When I try to do the same request in node it fails saying that the connection was refused:

```typescript
const response = await fetch(
    `http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/res-send`
);

```

Does the proxy refuse certain user agents or something?

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [January 25, 2024, 1:17am UTC](https://forum.dfinity.org/t/node-fetch-to-replica-connection-refused/26958/2 "2024-01-25T01:17:40Z")

</div>

This code works fine from a web browser running on localhost:

```typescript
fetch('http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/res-send').then((response) => response.text()).then((final) => console.log(final)).catch((error) => console.log(error))

```

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [January 25, 2024, 1:22am UTC](https://forum.dfinity.org/t/node-fetch-to-replica-connection-refused/26958/3 "2024-01-25T01:22:41Z")

</div>

Ah, okay so in newer versions of node DNS resolution for localhost is favoring ipv6 which apparently the ICP replica does not support.

See here: [http - ECONNREFUSED when making a request to localhost using fetch in Node.js - Stack Overflow](https://stackoverflow.com/questions/72390154/econnrefused-when-making-a-request-to-localhost-using-fetch-in-node-js)

This fixed it for me:

```auto
import * as dns from 'node:dns';
dns.setDefaultResultOrder('ipv4first');

```
