ECONNREFUSED error with node.js that does not occur in other clients

前端 未结 5 1777
面向向阳花
面向向阳花 2020-12-30 21:42

I\'m making an http request with the node.js client, and I get an ECONNREFUSED error. When I make what appears to be the same request

相关标签:
5条回答
  • 2020-12-30 21:56

    I had the same problem. I was able to resolve it by replacing the localhost or 127.0.0.1 by my system's ip address(use ifconfig for the ip address).

    0 讨论(0)
  • 2020-12-30 22:03

    I guess sometimes you just need to step away from the problem...

    I found a solution, but it doesn't seem to answer the question, and I don't really like the it.

    I changed the CherryPy server configuration to serve at 127.0.0.1 instead of localhost, and the node client started working.

    0 讨论(0)
  • 2020-12-30 22:07

    I exactly faced the same issue where I was accessing a third party url. I tried using dns (subdomain.domain.com) and ip (XXX.XXX.XXX.XXX) both but it did not work.

    After some struggle, later I realized that this was a problem at server (subdomain.domain.com) end which was not responsive and gone down.

    I disagree this is a problem with localhost / 127.0.0.1 (or domain name vs IP address). ( In above case, it's surely a case of incorrect host mapping)

    0 讨论(0)
  • 2020-12-30 22:11

    I disagree with Soman's disagreement.

    I've been pulling my hair out on this one, but yes, sure enough nodejs v0.10.24 and v0.10.25 refuse to connect to a PHP 5.4 development server (PHP's command line server) when invoked as:

    php -S localhost:8088
    

    The browser, curl, everything else connects just fine. Yet, sure enough, changing the binding address to be:

    php -S 127.0.0.1:8088 
    

    And nodejs' using xmlrpc connects just fine. This occurred on a Mac OS X 10.9.1. Very odd.

    0 讨论(0)
  • 2020-12-30 22:20

    I just faced the same problem.

    Note that Windows 7 by default doesn't include an entry for localhost in C:\Windows\System32\drivers\etc\hosts (wikipedia reference)

    Adding the entry for localhost has no effect with Node.js (0.10.25) as it apparently skips the hosts file completely.

    Use 127.0.0.1 as local address instead, this will works what ever is in your hosts file.

    0 讨论(0)
提交回复
热议问题