diff --git a/packages/next/cli/next-dev.ts b/packages/next/cli/next-dev.ts index 4619b0a0e7b494a..e8f432daba41160 100755 --- a/packages/next/cli/next-dev.ts +++ b/packages/next/cli/next-dev.ts @@ -73,12 +73,17 @@ const nextDev: cliCommand = (argv) => { const port = args['--port'] || (process.env.PORT && parseInt(process.env.PORT)) || 3000 - const host = args['--hostname'] || '0.0.0.0' - const appUrl = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}` + + // We do not set a default host value here to prevent breaking + // some set-ups that rely on listening on other interfaces + const host = args['--hostname'] + const appUrl = `http://${ + !host || host === '0.0.0.0' ? 'localhost' : host + }:${port}` startServer({ dir, dev: true, isNextDevCommand: true }, port, host) .then(async (app) => { - startedDevelopmentServer(appUrl, `${host}:${port}`) + startedDevelopmentServer(appUrl, `${host || '0.0.0.0'}:${port}`) // Start preflight after server is listening and ignore errors: preflight().catch(() => {}) // Finalize server bootup: