Reputation: 503
I was using nodejs + nano + couchdb for my application successfully up until today. For some reason all of a sudden I'm getting ECONNREFUSED when I try to run my application. If I try to query the database using the web browser or using a different application (java application) it works fine. I'm uncertain why just in this scenario it stopped working. I've been researching for the past 2 days and can't find any help. I believe this might have something to do with too many open connections, but that's a little bit out of my realm of knowledge. Can anyone provide me with any insight on debugging this issue or any direction I could go in? I should mention this couchdb lives on iriscouch
Upvotes: 1
Views: 976
Reputation: 5637
This is down to Node v18 now preferring an IPv6 address over and IPv4 address if two exist for the same hostname.
i.e. if your /etc/hosts
contains entries like this:
127.0.0.1 localhost
::1 localhost
Node v16 will say that "localhost" resolves to 127.0.0.1
where Node v18 will say "localhost" resolves to ::1
, the IPv6 equivalent. As CouchDB doesn't listen on an IPv6 port by default, then a connection to ::1
will be refused.
Solutions:
127.0.0.1
instead of localhost
in your URLs.127.0.0.1 my.pretend.host
in your /etc/hosts
file.bind_address = ::1
in couchdb.ini. You can then do curl 'http://USER:PASS@[::1]:5984/
.See
https://github.com/apache/couchdb-nano/issues/313#issuecomment-1321760360
Upvotes: 3
Reputation: 1667
Check the version of your node vs the expected node version of nano. It is possible that nano does not work with node > 16.
Upvotes: 1
Reputation: 358
Add more information about stack that you're using. But basically it's server machine doesn't want to allow connecting. Also try run your app with DEBUG=*, nano will log via console.log almost everything.
E.g. change in package.json
start command to node changetoyourapp.js DEBUG=*
I faced yesterday same issue with nodejitsu/iriscouch. Issue disappeared after some restarts.
Upvotes: 2