Thanks Bert. I am sorry but I failed to mention that I had tried every permutation of the hosts file with a myhost.local. Although obvious, it is good that you point it out - sometimes the most obvious things are overlooked. :)
With a /etc/hosts file of 127.0.0.1 localhost 255.255.255.255 broadcasthost::1 localhost myhost.local myhost fe80::1%lo0 localhost Node still refuses to connect to myhost.local on ::1. I rooted through Node's http.js but it wasn't obvious what was doing the name resolution - name resolution seemed to be in the socket code, but I didn't know the code well enough to locate it efficiently. Cheers, Brian On Tuesday, 5 March 2013 16:45:48 UTC-5, Bert Belder wrote: > > On Tuesday, March 5, 2013 5:58:06 PM UTC+1, Brian Hunt wrote: > >> I posted a question on stackoverflow detailing a problem I have >> encountered. The question is here: >> >> >> http://stackoverflow.com/questions/15227154/inexplicable-node-js-http-throwing-connect-econnrefused-ipv6 >> >> Unfortunately none of the answers have been helpful, so I am linking to >> it from here. The problem is this: >> >> I am getting Error: { [Error: connect ECONNREFUSED] code: >> 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' } whenever I >> try to connect using the http lib to an IPv6 address alias for localhost. >> My hosts is: >> >> 127.0.0.1 localhost myhost.local myhost255.255.255.255 broadcasthost::1 >> localhost myhost.local myhost >> fe80::1%lo0 localhost myhost.local myhost >> >> I am running a Python server bound to myhost.local on ::1.8080. >> >> Calling require('http').get('http://myhost.local:8080', ...) throws the >> above connect ECONNREFUSED. >> >> It has been no trouble connecting to the host from other programs, such >> as telnet or wget. >> >> I won't repeat all the details from the stackoverflow post, but there is >> some more information there that may help illustrate the problem. >> >> I would be very grateful for any thoughts and suggestions. >> >> Many thanks. >> >> Brian >> > > On your system "myhost.local" resolves to three different addresses > (127.0.0.1, ::1, and fe80::1). Node prefers ipv4 over ipv6 so it'll try to > connect to 127.0.0.1. Nothing is listening on 127.0.0.1:8080 so the > connect() syscall fails with ECONNREFUSED. Node doesn't retry with any of > the other resolved IPs - it just reports the error to you. A simple > solution would be to replace 'localhost' by the intended destination ip > address, '::1'. > > Whether this behavior is right is somewhat open for debate, but this is > what causes it. > > - Bert > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
