diff --git a/test/parallel/test-http-server-delete-parser.js b/test/parallel/test-http-server-delete-parser.js index 0c5eea90734170..4215ee2f9df74e 100644 --- a/test/parallel/test-http-server-delete-parser.js +++ b/test/parallel/test-http-server-delete-parser.js @@ -12,13 +12,13 @@ const server = http.createServer(common.mustCall((req, res) => { res.end(); })); -server.listen(1337, '127.0.0.1'); -server.unref(); - -const req = http.request({ - port: 1337, - host: '127.0.0.1', - method: 'GET', -}); +server.listen(0, '127.0.0.1', common.mustCall(() => { + const req = http.request({ + port: server.address().port, + host: '127.0.0.1', + method: 'GET', + }); + req.end(); +})); -req.end(); +server.unref();