diff --git a/test/parallel/test-https-connect-address-family.js b/test/parallel/test-https-connect-address-family.js index fa9baa528efa00..a345a70a57074b 100644 --- a/test/parallel/test-https-connect-address-family.js +++ b/test/parallel/test-https-connect-address-family.js @@ -33,7 +33,7 @@ function runTest() { dns.lookup('localhost', { family: 6, all: true }, (err, addresses) => { if (err) { - if (err.code === 'ENOTFOUND') + if (err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN') common.skip('localhost does not resolve to ::1'); throw err; diff --git a/test/parallel/test-net-better-error-messages-port-hostname.js b/test/parallel/test-net-better-error-messages-port-hostname.js index dac17141677dcb..818ea4bfff41f6 100644 --- a/test/parallel/test-net-better-error-messages-port-hostname.js +++ b/test/parallel/test-net-better-error-messages-port-hostname.js @@ -9,7 +9,13 @@ const c = net.createConnection(0, 'this.hostname.is.invalid'); c.on('connect', common.mustNotCall()); c.on('error', common.mustCall(function(e) { - assert.strictEqual(e.code, 'ENOTFOUND'); + // If Name Service Switch is available on the operating system then it + // might be configured differently (/etc/nsswitch.conf). + // If the system is configured with no dns the error code will be EAI_AGAIN, + // but if there are more services after the dns entry, for example some + // linux distributions ship a myhostname service by default which would + // still produce the ENOTFOUND error. + assert.ok(e.code === 'ENOTFOUND' || e.code === 'EAI_AGAIN'); assert.strictEqual(e.port, 0); assert.strictEqual(e.hostname, 'this.hostname.is.invalid'); })); diff --git a/test/parallel/test-net-connect-immediate-finish.js b/test/parallel/test-net-connect-immediate-finish.js index 1b65ce15ab8a1c..e2e5e1c6715b9a 100644 --- a/test/parallel/test-net-connect-immediate-finish.js +++ b/test/parallel/test-net-connect-immediate-finish.js @@ -32,7 +32,13 @@ const client = net.connect({ client.once('error', common.mustCall((err) => { assert(err); assert.strictEqual(err.code, err.errno); - assert.strictEqual(err.code, 'ENOTFOUND'); + // If Name Service Switch is available on the operating system then it + // might be configured differently (/etc/nsswitch.conf). + // If the system is configured with no dns the error code will be EAI_AGAIN, + // but if there are more services after the dns entry, for example some + // linux distributions ship a myhostname service by default which would + // still produce the ENOTFOUND error. + assert.ok(err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN'); assert.strictEqual(err.host, err.hostname); assert.strictEqual(err.host, 'this.hostname.is.invalid'); assert.strictEqual(err.syscall, 'getaddrinfo'); diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js index 663e9399b610ce..b0623c6cf603ec 100644 --- a/test/parallel/test-tls-connect-address-family.js +++ b/test/parallel/test-tls-connect-address-family.js @@ -32,7 +32,7 @@ function runTest() { dns.lookup('localhost', { family: 6, all: true }, (err, addresses) => { if (err) { - if (err.code === 'ENOTFOUND') + if (err.code === 'ENOTFOUND' || err.code === 'EAI_AGAIN') common.skip('localhost does not resolve to ::1'); throw err;