apache / apache/couchdb-nano

Linode VM and Nodejs preferred IPV6?

Open
#292 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
689
Forks
167
Avg merge
1h
Merged PRs (30d)
1

Description

Linux distribution: Arch Linux

On my Linode VM, I upgraded from Node 16 to Node 17.3. After this, I could no longer connect via nano to my couchdb. It seems that in my VM, the port 5984 is redirected to another open port e.g 127.0.0.1:5984 -> 127.0.0.1:xxxxx. However, it does not create a redirect for ::1:5984 so I was getting a connection refused.

I found this by doing a console.log(response) in ../node_modules/nano/lib/nano.js just above line 137 (a socket error)

> Error: connect ECONNREFUSED ::1:5984
3 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
4 errno: -111,
5 code: 'ECONNREFUSED',
6 syscall: 'connect',
7 address: '::1',
8 port: 5984,
9 config: {
10 url: 'http://localhost:5984/musiccat/_find',
11 method: 'post',
12 data: '{"selector":{"$or":[{"dtype":"album"},{"dtype":"code","code_type":"format"}]},"fields":["_id","dtype","code_type","name","images","format","_attachments"],"use_index":"dtype-name-index","limit":999999}',
13 headers: {
14 Accept: 'application/json',
15 'Content-Type': 'application/json',
16 'user-agent': 'nano/9.0.5 (Node.js v17.3.0)',
17 'Accept-Encoding': 'deflate, gzip',
18 'Content-Length': 201
19 },...
>

On my LInode VM, I disabled IPV6 for all interfaces (in /etc/sysctl.d/40-ipv6.conf). After doing that, the redirects are gone and the connection starting working again. It took many hours to find this problem. Today I had found an entry on Reddit where new versions of Nodejs are now preferring IPV6. However, when I look at Nodejs net.socketAddress, the default family is still 'ipv4'.

I am not sure how to configure the nano connection to only use IPV4 or if something needs to change in the nano library to help with this issue so people don't have to completely disable IPV6 on their systems.

Contributor guide

Open the contributing guide

Research direction

Start with nano/lib/nano.js around line 137 and the reported Node.js net.socketAddress behavior. Reproduce the localhost connection failure on an Arch Linux or Linode environment with IPv6 enabled, then determine a clear supported change or configuration path that avoids the IPv6-only connection refusal.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.