ConnectionRefused on localhost! Frontend unable to connect to my backend

as the title says, since yesterday my localhost is also behaving weirdly.

Uncaught (in promise) Error: Server returned an error:
  Code: 504 (Gateway Timeout)
  Body: Error occured while trying to proxy to: localhost:8080/api/v2/canister/rrkah-fqaaa-aaaaa-aaaaq-cai/call

    at HttpAgent.call (index.js:134)
    at async caller (actor.js:174)
    at async HTMLButtonElement.<anonymous> (index.js:452)

logs from npm

[HPM] Error occurred while trying to proxy request /api/v2/status from localhost:8080 to http://localhost:8000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /api/v2/canister/rrkah-fqaaa-aaaaa-aaaaq-cai/call from localhost:8080 to http://localhost:8000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /api/v2/canister/rrkah-fqaaa-aaaaa-aaaaq-cai/call from localhost:8080 to http://localhost:8000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

is anyone else facing this issue?
I have not configured the canister rrkah-fqaaa-aaaaa-aaaaq-cai anywhere

Why would the connection be refused in my local set up?

Are you running an odd numbered node version (13-15-17)? I remember reading something similar on discord. Might want to check if you can upgrade / downgrade to an even version.

From the discord:

Kyle
 ā€” 
12/03/2021
I think we've encountered that on non-stable Node.js versions. We support 12, 14, and 16

Kyle
 ā€” 
12/03/2021
I think it's an issue with the http middleware that webpack depends on for proxies. There's nothing I could identify that would make it work on Node 17 when I was looking into it

2 Likes

Iā€™m having this same issue. Did you ever find a solution?

1 Like

i switched my node version from v17.0.1 to v16.3.1 and it did the trick!

1 Like

Thanks for the solution.
I also encountered the same problem with node version 17. when I lowered the node version to 16, the error went away.