From 8c1723b5b67d3b46437fcc7fc07c1efcb2138b19 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 03:58:23 +0000 Subject: [PATCH 01/10] Initial plan From 91c0b7de98a1d53077364674620fd042b7a0b786 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 04:04:41 +0000 Subject: [PATCH 02/10] fix: allow specific IP host binding when wildcard port is in use Agent-Logs-Url: https://github.com/vitejs/vite/sessions/9201cbf8-eb3b-4af9-965b-ca88e42eda6a Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> --- packages/vite/src/node/__tests__/http.spec.ts | 122 ++++++++++++++++++ packages/vite/src/node/http.ts | 24 ++++ 2 files changed, 146 insertions(+) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index ec9d8d29245a7e..01bf3df9d008ec 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -213,4 +213,126 @@ describe('port detection', () => { `Port ${BASE_PORT} is already in use`, ) }) + + describe('specific host with wildcard conflict', () => { + function mockWildcardEADDRINUSE() { + const originalCreateServer = net.createServer.bind(net) + return vi.spyOn(net, 'createServer').mockImplementation(() => { + const server = originalCreateServer() + const originalListen = server.listen.bind(server) + // @ts-expect-error this is the overload used internally + server.listen = ( + port: number, + host: string, + ...args: unknown[] + ): net.Server => { + if (wildcardHosts.has(host)) { + process.nextTick(() => { + const err: NodeJS.ErrnoException = new Error( + `listen EADDRINUSE: address already in use ${host}:${port}`, + ) + err.code = 'EADDRINUSE' + server.emit('error', err) + }) + return server + } + // @ts-expect-error this is the overload used internally + return originalListen(port, host, ...args) + } + return server + }) + } + + test('allows binding to specific host when wildcard port is in use', async () => { + using _ = mockWildcardEADDRINUSE() + + viteServer = await createServer({ + root: import.meta.dirname, + logLevel: 'silent', + server: { + port: BASE_PORT, + host: '127.0.0.1', + strictPort: false, + ws: false, + }, + }) + await viteServer.listen() + + const address = viteServer.httpServer!.address() + expect(address).toStrictEqual( + expect.objectContaining({ port: BASE_PORT }), + ) + }) + + test('allows binding to specific host with strictPort when wildcard port is in use', async () => { + using _ = mockWildcardEADDRINUSE() + + viteServer = await createServer({ + root: import.meta.dirname, + logLevel: 'silent', + server: { + port: BASE_PORT, + host: '127.0.0.1', + strictPort: true, + ws: false, + }, + }) + await viteServer.listen() + + const address = viteServer.httpServer!.address() + expect(address).toStrictEqual( + expect.objectContaining({ port: BASE_PORT }), + ) + }) + + test('emits warning when specific host binds but wildcard port is in use', async () => { + using _ = mockWildcardEADDRINUSE() + + const warnMessages: string[] = [] + viteServer = await createServer({ + root: import.meta.dirname, + customLogger: { + info: () => {}, + warn: (msg) => warnMessages.push(msg), + warnOnce: () => {}, + error: () => {}, + clearScreen: () => {}, + hasErrorLogged: () => false, + hasWarned: false, + }, + server: { + port: BASE_PORT, + host: '127.0.0.1', + strictPort: false, + ws: false, + }, + }) + await viteServer.listen() + + expect(warnMessages.some((msg) => msg.includes(`wildcard`))).toBe(true) + }) + + test('throws when specific host port is also in use with strictPort', async () => { + await using _blockingServer = await createSimpleServer( + BASE_PORT, + '127.0.0.1', + ) + using _ = mockWildcardEADDRINUSE() + + viteServer = await createServer({ + root: import.meta.dirname, + logLevel: 'silent', + server: { + port: BASE_PORT, + host: '127.0.0.1', + strictPort: true, + ws: false, + }, + }) + + await expect(viteServer.listen()).rejects.toThrow( + `Port ${BASE_PORT} is already in use`, + ) + }) + }) }) diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index 78ef9060ababcd..bf5fd71b9eaf2e 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -226,6 +226,13 @@ export async function httpServerStart( ): Promise { const { port: startPort, strictPort, host, logger } = serverOptions + // When the configured host is an explicit IP address (not a hostname like + // "localhost" and not a wildcard), allow binding even if the wildcard + // pre-check fails. A port may be in use on other interfaces while remaining + // free on the specific IP address. + const isSpecificIp = + host !== undefined && net.isIP(host) > 0 && !wildcardHosts.has(host) + for (let port = startPort; port <= MAX_PORT; port++) { // Pre-check port availability on wildcard addresses (0.0.0.0, ::) // so that we avoid conflicts with other servers listening on all interfaces @@ -237,6 +244,23 @@ export async function httpServerStart( if (result.error.code !== 'EADDRINUSE') { throw result.error } + } else if (isSpecificIp) { + // Port is not available on a wildcard address, but we have a specific + // host configured. The port may still be free on that specific host, so + // try binding directly rather than skipping to the next port. + const result = await tryBindServer(httpServer, port, host) + if (result.success) { + logger.warn( + colors.yellow( + `Port ${port} is in use on a wildcard address, but ${host}:${port} is available. ` + + `There may be another server running on a wildcard IP on port ${port}.`, + ), + ) + return port + } + if (result.error.code !== 'EADDRINUSE') { + throw result.error + } } if (strictPort) { From 1f399a1d23936cf230d2e2c5ab8cc3d4f9488605 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 04:07:05 +0000 Subject: [PATCH 03/10] fix: rename isSpecificIp to isSpecificIpHost and use descriptive mock variable names in tests Agent-Logs-Url: https://github.com/vitejs/vite/sessions/9201cbf8-eb3b-4af9-965b-ca88e42eda6a Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> --- packages/vite/src/node/__tests__/http.spec.ts | 10 ++++++---- packages/vite/src/node/http.ts | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index 01bf3df9d008ec..5b4ca3446f2f11 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -244,7 +244,7 @@ describe('port detection', () => { } test('allows binding to specific host when wildcard port is in use', async () => { - using _ = mockWildcardEADDRINUSE() + using wildcardMock = mockWildcardEADDRINUSE() viteServer = await createServer({ root: import.meta.dirname, @@ -262,10 +262,11 @@ describe('port detection', () => { expect(address).toStrictEqual( expect.objectContaining({ port: BASE_PORT }), ) + expect(wildcardMock).toHaveBeenCalled() }) test('allows binding to specific host with strictPort when wildcard port is in use', async () => { - using _ = mockWildcardEADDRINUSE() + using wildcardMock = mockWildcardEADDRINUSE() viteServer = await createServer({ root: import.meta.dirname, @@ -283,10 +284,11 @@ describe('port detection', () => { expect(address).toStrictEqual( expect.objectContaining({ port: BASE_PORT }), ) + expect(wildcardMock).toHaveBeenCalled() }) test('emits warning when specific host binds but wildcard port is in use', async () => { - using _ = mockWildcardEADDRINUSE() + using _wildcardMock = mockWildcardEADDRINUSE() const warnMessages: string[] = [] viteServer = await createServer({ @@ -317,7 +319,7 @@ describe('port detection', () => { BASE_PORT, '127.0.0.1', ) - using _ = mockWildcardEADDRINUSE() + using _wildcardMock = mockWildcardEADDRINUSE() viteServer = await createServer({ root: import.meta.dirname, diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index bf5fd71b9eaf2e..b111ebd1ca9d96 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -230,7 +230,7 @@ export async function httpServerStart( // "localhost" and not a wildcard), allow binding even if the wildcard // pre-check fails. A port may be in use on other interfaces while remaining // free on the specific IP address. - const isSpecificIp = + const isSpecificIpHost = host !== undefined && net.isIP(host) > 0 && !wildcardHosts.has(host) for (let port = startPort; port <= MAX_PORT; port++) { @@ -244,7 +244,7 @@ export async function httpServerStart( if (result.error.code !== 'EADDRINUSE') { throw result.error } - } else if (isSpecificIp) { + } else if (isSpecificIpHost) { // Port is not available on a wildcard address, but we have a specific // host configured. The port may still be free on that specific host, so // try binding directly rather than skipping to the next port. From 4e5d5403ef607b1eb32322172528b999d19c0e16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 04:34:08 +0000 Subject: [PATCH 04/10] fix: use strictPort instead of isSpecificIpHost for wildcard bypass condition Agent-Logs-Url: https://github.com/vitejs/vite/sessions/1310d5a7-55fd-498d-9b49-e3224f8aa89a Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> --- packages/vite/src/node/__tests__/http.spec.ts | 26 ++----------------- packages/vite/src/node/http.ts | 17 ++++-------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index 5b4ca3446f2f11..23b806388ee772 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -243,28 +243,6 @@ describe('port detection', () => { }) } - test('allows binding to specific host when wildcard port is in use', async () => { - using wildcardMock = mockWildcardEADDRINUSE() - - viteServer = await createServer({ - root: import.meta.dirname, - logLevel: 'silent', - server: { - port: BASE_PORT, - host: '127.0.0.1', - strictPort: false, - ws: false, - }, - }) - await viteServer.listen() - - const address = viteServer.httpServer!.address() - expect(address).toStrictEqual( - expect.objectContaining({ port: BASE_PORT }), - ) - expect(wildcardMock).toHaveBeenCalled() - }) - test('allows binding to specific host with strictPort when wildcard port is in use', async () => { using wildcardMock = mockWildcardEADDRINUSE() @@ -287,7 +265,7 @@ describe('port detection', () => { expect(wildcardMock).toHaveBeenCalled() }) - test('emits warning when specific host binds but wildcard port is in use', async () => { + test('emits warning when host binds with strictPort but wildcard port is in use', async () => { using _wildcardMock = mockWildcardEADDRINUSE() const warnMessages: string[] = [] @@ -305,7 +283,7 @@ describe('port detection', () => { server: { port: BASE_PORT, host: '127.0.0.1', - strictPort: false, + strictPort: true, ws: false, }, }) diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index b111ebd1ca9d96..7219331465ccb2 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -226,13 +226,6 @@ export async function httpServerStart( ): Promise { const { port: startPort, strictPort, host, logger } = serverOptions - // When the configured host is an explicit IP address (not a hostname like - // "localhost" and not a wildcard), allow binding even if the wildcard - // pre-check fails. A port may be in use on other interfaces while remaining - // free on the specific IP address. - const isSpecificIpHost = - host !== undefined && net.isIP(host) > 0 && !wildcardHosts.has(host) - for (let port = startPort; port <= MAX_PORT; port++) { // Pre-check port availability on wildcard addresses (0.0.0.0, ::) // so that we avoid conflicts with other servers listening on all interfaces @@ -244,15 +237,15 @@ export async function httpServerStart( if (result.error.code !== 'EADDRINUSE') { throw result.error } - } else if (isSpecificIpHost) { - // Port is not available on a wildcard address, but we have a specific - // host configured. The port may still be free on that specific host, so - // try binding directly rather than skipping to the next port. + } else if (strictPort) { + // Port is not available on a wildcard address, but strictPort is set so + // we must use this exact port. The port may still be free on the + // configured host, so try binding directly before giving up. const result = await tryBindServer(httpServer, port, host) if (result.success) { logger.warn( colors.yellow( - `Port ${port} is in use on a wildcard address, but ${host}:${port} is available. ` + + `Port ${port} is in use on a wildcard address, but ${host ?? 'localhost'}:${port} is available. ` + `There may be another server running on a wildcard IP on port ${port}.`, ), ) From a43ffaf1c41c1d1e76110dcf533824279711f7b0 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 6 Apr 2026 13:51:49 +0900 Subject: [PATCH 05/10] chore: tweak test --- packages/vite/src/node/__tests__/http.spec.ts | 121 ++++-------------- 1 file changed, 24 insertions(+), 97 deletions(-) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index 23b806388ee772..7cd6794373384e 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -214,105 +214,32 @@ describe('port detection', () => { ) }) - describe('specific host with wildcard conflict', () => { - function mockWildcardEADDRINUSE() { - const originalCreateServer = net.createServer.bind(net) - return vi.spyOn(net, 'createServer').mockImplementation(() => { - const server = originalCreateServer() - const originalListen = server.listen.bind(server) - // @ts-expect-error this is the overload used internally - server.listen = ( - port: number, - host: string, - ...args: unknown[] - ): net.Server => { - if (wildcardHosts.has(host)) { - process.nextTick(() => { - const err: NodeJS.ErrnoException = new Error( - `listen EADDRINUSE: address already in use ${host}:${port}`, - ) - err.code = 'EADDRINUSE' - server.emit('error', err) - }) - return server - } - // @ts-expect-error this is the overload used internally - return originalListen(port, host, ...args) - } - return server - }) - } + test('allows binding to specific host with strictPort when wildcard port is in use', async () => { + await using _wildcardServer = await createSimpleServer(BASE_PORT, '0.0.0.0') - test('allows binding to specific host with strictPort when wildcard port is in use', async () => { - using wildcardMock = mockWildcardEADDRINUSE() - - viteServer = await createServer({ - root: import.meta.dirname, - logLevel: 'silent', - server: { - port: BASE_PORT, - host: '127.0.0.1', - strictPort: true, - ws: false, - }, - }) - await viteServer.listen() - - const address = viteServer.httpServer!.address() - expect(address).toStrictEqual( - expect.objectContaining({ port: BASE_PORT }), - ) - expect(wildcardMock).toHaveBeenCalled() - }) - - test('emits warning when host binds with strictPort but wildcard port is in use', async () => { - using _wildcardMock = mockWildcardEADDRINUSE() - - const warnMessages: string[] = [] - viteServer = await createServer({ - root: import.meta.dirname, - customLogger: { - info: () => {}, - warn: (msg) => warnMessages.push(msg), - warnOnce: () => {}, - error: () => {}, - clearScreen: () => {}, - hasErrorLogged: () => false, - hasWarned: false, - }, - server: { - port: BASE_PORT, - host: '127.0.0.1', - strictPort: true, - ws: false, - }, - }) - await viteServer.listen() - - expect(warnMessages.some((msg) => msg.includes(`wildcard`))).toBe(true) + const warnMessages: string[] = [] + viteServer = await createServer({ + root: import.meta.dirname, + customLogger: { + info: () => {}, + warn: (msg) => warnMessages.push(msg), + warnOnce: () => {}, + error: () => {}, + clearScreen: () => {}, + hasErrorLogged: () => false, + hasWarned: false, + }, + server: { + port: BASE_PORT, + host: '127.0.0.1', + strictPort: true, + ws: false, + }, }) + await viteServer.listen() - test('throws when specific host port is also in use with strictPort', async () => { - await using _blockingServer = await createSimpleServer( - BASE_PORT, - '127.0.0.1', - ) - using _wildcardMock = mockWildcardEADDRINUSE() - - viteServer = await createServer({ - root: import.meta.dirname, - logLevel: 'silent', - server: { - port: BASE_PORT, - host: '127.0.0.1', - strictPort: true, - ws: false, - }, - }) - - await expect(viteServer.listen()).rejects.toThrow( - `Port ${BASE_PORT} is already in use`, - ) - }) + const address = viteServer.httpServer!.address() + expect(address).toStrictEqual(expect.objectContaining({ port: BASE_PORT })) + expect(warnMessages).toContainEqual(expect.stringContaining('wildcard')) }) }) From 730ea61a3fbf7b05c3fdbdad1d9cc65dcd901bb7 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 6 Apr 2026 14:54:24 +0900 Subject: [PATCH 06/10] test: try --- packages/vite/src/node/__tests__/http.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index 7cd6794373384e..8258f83d366e3f 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -215,7 +215,7 @@ describe('port detection', () => { }) test('allows binding to specific host with strictPort when wildcard port is in use', async () => { - await using _wildcardServer = await createSimpleServer(BASE_PORT, '0.0.0.0') + await using _wildcardServer = await createSimpleServer(BASE_PORT, '::1') const warnMessages: string[] = [] viteServer = await createServer({ From 5038b268b2ac9d2cd994f4b7d213bfdb3edd68c6 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 6 Apr 2026 14:59:15 +0900 Subject: [PATCH 07/10] test: try --- packages/vite/src/node/__tests__/http.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index 8258f83d366e3f..d93190ae0657e7 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -215,7 +215,11 @@ describe('port detection', () => { }) test('allows binding to specific host with strictPort when wildcard port is in use', async () => { - await using _wildcardServer = await createSimpleServer(BASE_PORT, '::1') + await using _wildcardServer4 = await createSimpleServer( + BASE_PORT, + '0.0.0.0', + ) + await using _wildcardServer6 = await createSimpleServer(BASE_PORT, '::1') const warnMessages: string[] = [] viteServer = await createServer({ From 8040a612f63a8983c12940bdeb574977e692b7eb Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:06:05 +0900 Subject: [PATCH 08/10] test: try --- packages/vite/src/node/__tests__/http.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index d93190ae0657e7..02b2404b1a4b3e 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -219,7 +219,7 @@ describe('port detection', () => { BASE_PORT, '0.0.0.0', ) - await using _wildcardServer6 = await createSimpleServer(BASE_PORT, '::1') + await using _wildcardServer6 = await createSimpleServer(BASE_PORT, '::') const warnMessages: string[] = [] viteServer = await createServer({ From f8ecf3f8689a563b4faec1e3499ca21c614aacec Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:11:16 +0900 Subject: [PATCH 09/10] test: try --- packages/vite/src/node/__tests__/http.spec.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/vite/src/node/__tests__/http.spec.ts b/packages/vite/src/node/__tests__/http.spec.ts index 02b2404b1a4b3e..3c10fae328a081 100644 --- a/packages/vite/src/node/__tests__/http.spec.ts +++ b/packages/vite/src/node/__tests__/http.spec.ts @@ -215,11 +215,7 @@ describe('port detection', () => { }) test('allows binding to specific host with strictPort when wildcard port is in use', async () => { - await using _wildcardServer4 = await createSimpleServer( - BASE_PORT, - '0.0.0.0', - ) - await using _wildcardServer6 = await createSimpleServer(BASE_PORT, '::') + await using _wildcardServer = await createSimpleServer(BASE_PORT, '0.0.0.0') const warnMessages: string[] = [] viteServer = await createServer({ @@ -240,7 +236,16 @@ describe('port detection', () => { ws: false, }, }) - await viteServer.listen() + + try { + await viteServer.listen() + } catch (e) { + // it may not be allowed to bind to specific host when wildcard port is in use + expect(() => { + throw e + }).toThrow(`Port ${BASE_PORT} is already in use`) + return + } const address = viteServer.httpServer!.address() expect(address).toStrictEqual(expect.objectContaining({ port: BASE_PORT })) From 80b7cbb34f071fc606c4b7fb95d3b9b64fefadae Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Wed, 8 Apr 2026 13:24:33 +0900 Subject: [PATCH 10/10] refactor: merge "port already in use" error in the if-else block --- packages/vite/src/node/http.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index 7219331465ccb2..ecca383e3d6e7a 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -229,37 +229,38 @@ export async function httpServerStart( for (let port = startPort; port <= MAX_PORT; port++) { // Pre-check port availability on wildcard addresses (0.0.0.0, ::) // so that we avoid conflicts with other servers listening on all interfaces - if (await isPortAvailable(port)) { + const portAvailableOnWildcard = await isPortAvailable(port) + + // If port is not available on a wildcard address but strictPort is set, + // we still try binding directly before giving up. + if (strictPort) { const result = await tryBindServer(httpServer, port, host) if (result.success) { + if (!portAvailableOnWildcard) { + logger.warn( + colors.yellow( + `Port ${port} is in use on a wildcard address, but ${host ?? 'localhost'}:${port} is available. ` + + `There may be another server running on a wildcard IP on port ${port}.`, + ), + ) + } return port } if (result.error.code !== 'EADDRINUSE') { throw result.error } - } else if (strictPort) { - // Port is not available on a wildcard address, but strictPort is set so - // we must use this exact port. The port may still be free on the - // configured host, so try binding directly before giving up. + throw new Error(`Port ${port} is already in use`) + } + + if (portAvailableOnWildcard) { const result = await tryBindServer(httpServer, port, host) if (result.success) { - logger.warn( - colors.yellow( - `Port ${port} is in use on a wildcard address, but ${host ?? 'localhost'}:${port} is available. ` + - `There may be another server running on a wildcard IP on port ${port}.`, - ), - ) return port } if (result.error.code !== 'EADDRINUSE') { throw result.error } } - - if (strictPort) { - throw new Error(`Port ${port} is already in use`) - } - logger.info(`Port ${port} is in use, trying another one...`) } throw new Error(