skip to Main Content

I have one Node.js Azure function running on a Windows 11 system at http://localhost:7071/api/FunctionName.

I can execute the function by calling it from a browser window no problem.

Now when I call it from another node app running on localhost with axios or fetch, I get an ECONNREFUSED error.

I get the same results whether I’m running from NPM start or inside VS Code. It works fine on one system.

Any suggestions? – this used to work no problem.

Thanks.

2

Answers


  1. Chosen as BEST ANSWER

    I just figured out a fix - calling the localhost IP address directly works: http://127.0.0.1/api/FunctionName.

    Now I need to figure out what caused the configuration change.


  2. there has been a breaking change on dns resolution for localhost since node 17.

    Your solution works fine because providing the Ip explicitly prevents the dns resolution mechanism.

    other possible solutions:

    1- force the node app to use ipv4 first:

    const dns = require('dns');
    dns.setDefaultResultOrder('ipv4first');
    

    2 – downgrade node to version 16

    this issue is also reported on github:
    #40702

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search