# Webpack Proxy - ECONNREFUSED for proxy to api

**URL:** <https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263>\
**Category:** Developers\
**Created:** [December 2, 2021, 8:01pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263 "2021-12-02T20:01:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbeekman](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mbeekman/32/2675_2.png) [@mbeekman](https://forum.dfinity.org/u/mbeekman)\
**Post date:** [December 2, 2021, 8:01pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/1 "2021-12-02T20:01:23Z")

</div>

on a fresh “hello” project I get:  
Error occurred while proxying request localhost:8080/api/v2/status to [http://localhost:8000/](http://localhost:8000/) [ECONNREFUSED]

on the webpack server in a development environment. The canisters run fine on the replica and if I go directly to the replica i.e “localhost:8000/api/v2/status” it works, same with “127.0.0.1:8080/api/v2/status” and if I change the webpack proxy to “127.0.0.1” or change the dfx.json to start the replica on “localhost” everything works fine … I just did not have to do that in the past.

Anyone have any thoughts on this one? I have Mac M1 …

---

<div class="post-metadata">

**Author:** ![mbeekman](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mbeekman/32/2675_2.png) [@mbeekman](https://forum.dfinity.org/u/mbeekman)\
**Post date:** [December 3, 2021, 3:26pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/2 "2021-12-03T15:26:32Z")

</div>

Hello Forum - FYI, I also posted this in the Dfinity Discord and @anon74414410 (Kyle) from the Dfinity team said that this behavior was most likely from a newer version of node.js.

So, I had 17.2 active and he said the SDK supports 12, 14, and 16 …

I unlinked 17, installed 16 and linked it …

for those that use “brew” on a Mac, I did this:

```auto
brew install node@16
brew unlink node
brew link --overwrite --dry-run node@16
#just to check I ran the --dry-run ... my machine wanted an "--overwrite" to complete
brew link --overwrite node@16

```

then started dfx and web pack dev server and it worked as before.

Thanks Kyle …

Updated this case in case others get stuck …

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [December 3, 2021, 3:36pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/3 "2021-12-03T15:36:26Z")

</div>

I really hope this bug doesn’t make it into a stable node.js release so that I don’t have the excuse anymore 😬

---

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [August 22, 2022, 9:10pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/4 "2022-08-22T21:10:40Z")

</div>

Recently ran into this same bug with NodeJS version v18.1.0.

Reverting to 16.xx.xx (stable) fixed it.

I’m a huge fan of [nvm](https://github.com/nvm-sh/nvm) (also installable via brew) for switching between node versions.

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [August 23, 2022, 2:09am UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/5 "2022-08-23T02:09:42Z")

</div>

I’m not sure I followed this thread correctly, but maybe the problem can be explained by this:

> [@Development workflow: quickly test code modifications](https://forum.dfinity.org/t/development-workflow-quickly-test-code-modifications/1793/22):
>
> Note to self for the future: bind to 127.0.0.1:8000 instead of localhost:8000 since binding to localhost sometimes uses ipv6’s [::1] address, which won’t work with [cid].localhost:8000 addresses.

---

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [December 30, 2022, 4:53am UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/6 "2022-12-30T04:53:28Z")

</div>

@anon74414410

This bug is now in a stable NodeJS release (18.12.1)

As previously mentioned, this issue occurs when using Node 18, but is fixed (does not occur) when using Node 16.

Is specific bug (in the post) with webpack, webpack plugins, or something else entirely? It would be nice to be able to spin up a dev-server without having to switch back to Node 16.

  
  

Additionally, it seems like there are a few agent-js features now (such as node compatibility flag and the native fetch implementation with `createActor`) that are using Node versions \>= 18, so it might be time to fully support Node 18 😅 :

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [January 4, 2023, 6:09pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/7 "2023-01-04T18:09:41Z")

</div>

Yes, node 18 is fully supported, and Paul is correct. Replace `localhost` with `127.0.0.1` in your webpack config and you should be good to go

---

<div class="post-metadata">

**Author:** ![axelwp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/axelwp/32/9019_2.png) [@axelwp](https://forum.dfinity.org/u/axelwp)\
**Post date:** [January 12, 2023, 2:29am UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/8 "2023-01-12T02:29:34Z")

</div>

I’m just now running into this issue with my app after adding a local ledger canister. I’ve replaced the localhost with 127.0.0.1 in my webpack config as well as binding that address as described in the thread linked by @paulyoung but I am unable to make calls or queries from my frontend canister to my backend canister, nor am I able to check the status at localhost:8080/api/v2/status. I’m able to make calls and queries to it from the console and Candid interface so I’m confused why it’s refusing connections from some actors.  
This is using node 16.14.2

---

<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 12, 2023, 7:22am UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/9 "2023-01-12T07:22:14Z")

</div>

The default port recently switched to 4943. Can you try `localhost:4943/api/v2/status`? On my machine, this works

---

<div class="post-metadata">

**Author:** ![axelwp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/axelwp/32/9019_2.png) [@axelwp](https://forum.dfinity.org/u/axelwp)\
**Post date:** [January 12, 2023, 7:46pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/10 "2023-01-12T19:46:15Z")

</div>

This worked, thank you so much!

---

<div class="post-metadata">

**Author:** ![successaje](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/successaje/32/7924_2.png) [@successaje](https://forum.dfinity.org/u/successaje)\
**Post date:** [May 30, 2024, 11:44pm UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/11 "2024-05-30T23:44:38Z")

</div>

I get similar error too.

`[webpack-dev-server] [HPM] Error occurred while proxying request localhost:8081/api/v2/status to http://127.0.0.1:4943/api/v2/status? [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)`

I even get something similar when i try to test http outcalls functions locally.

---

<div class="post-metadata">

**Author:** ![successaje](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/successaje/32/7924_2.png) [@successaje](https://forum.dfinity.org/u/successaje)\
**Post date:** [May 31, 2024, 12:23am UTC](https://forum.dfinity.org/t/webpack-proxy-econnrefused-for-proxy-to-api/9263/12 "2024-05-31T00:23:28Z")

</div>

Already fixed by adding this to the dfx.json.

` "networks": { "local": { "bind": "127.0.0.1:4943", "type": "ephemeral" } },`
