diff --git a/test/parallel/test-https-connect-address-family.js b/test/parallel/test-https-connect-address-family.js index 76a12ef5d5dc0e..7c111dc386da1b 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 01b41d3b212b44..467b424b6cbbac 100644 --- a/test/parallel/test-net-connect-immediate-finish.js +++ b/test/parallel/test-net-connect-immediate-finish.js @@ -11,7 +11,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 afacd5a39027a0..41b218a5a4f41a 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;