react/create-react-app · error · Error
Could not find an open port at ${host}.\nNetwork error messa
Error message
Could not find an open port at ${host}.\nNetwork error message: ${err.message}\n What it means
WebpackDevServerUtils.choosePort first probes the host with a network check before scanning for a free port. If that probe itself rejects (the host is unreachable / DNS fails), the error callback throws this message combining the host and the underlying network error. It is distinct from 'port in use', which is handled interactively above.
Source
Thrown at packages/react-dev-utils/WebpackDevServerUtils.js:428
message +
`${existingProcess ? ` Probably:\n ${existingProcess}` : ''}`
) + '\n\nWould you like to run the app on another port instead?',
initial: true,
};
prompts(question).then(answer => {
if (answer.shouldChangePort) {
resolve(port);
} else {
resolve(null);
}
});
} else {
console.log(chalk.red(message));
resolve(null);
}
}),
err => {
throw new Error(
chalk.red(`Could not find an open port at ${chalk.bold(host)}.`) +
'\n' +
('Network error message: ' + err.message || err) +
'\n'
);
}
);
}
module.exports = {
choosePort,
createCompiler,
prepareProxy,
prepareUrls,
};
View on GitHub (pinned to 6254386531)
Solutions
- Set HOST to a valid local interface: `HOST=127.0.0.1 npm start` (or localhost).
- If you need LAN access, confirm the chosen HOST is assigned to a local interface (run ifconfig/ipconfig) before starting.
- Inside Docker, bind to 0.0.0.0 only if the container networking permits and you intend external access; otherwise use 127.0.0.1.
- Disable network adapters that conflict, or reconnect VPN, then retry.
Example fix
// before // .env HOST=dev.local.example // after // .env HOST=127.0.0.1
Defensive patterns
Strategy: validation
Validate before calling
const net = require('net');
const dns = require('dns').promises;
async function canReachHost(host) {
// loopback/ips are bindable; hostnames must resolve
if (net.isIP(host)) return true;
try { await dns.lookup(host); return true; } catch { return false; }
}
// before choosePort:
const host = process.env.HOST || '0.0.0.0';
if (!(await canReachHost(host))) {
throw new Error(`HOST '${host}' is not reachable/bindable on this machine`);
} Type guard
const isBindableHost = (h) => h === 'localhost' || h === '0.0.0.0' || net.isIP(h) !== 0;
Try / catch
try {
const port = await choosePort(process.env.HOST || '0.0.0.0', 3000);
if (!port) process.exit(0);
} catch (e) {
if (/Could not find an open port|Network error/.test(e.message)) {
console.error('HOST not reachable. Try HOST=127.0.0.1');
process.exit(1);
}
throw e;
} Prevention
- Default HOST to 127.0.0.1 in .env unless you need LAN exposure.
- Validate the HOST against local interfaces before starting the dev server.
- Inside Docker, use HOST=0.0.0.0 only when container networking allows it.
- Reconnect VPN / verify DNS if a custom hostname fails.
When it happens
Trigger: choosePort(host, defaultPort) is called and the internal is-port-reachable/network probe for `host` rejects. The rejection handler runs and throws. Common when HOST is set to a hostname the machine cannot bind or resolve.
Common situations: Setting HOST to a non-loopback address not assigned to any interface. Docker/container setups where the configured HOST isn't available inside the namespace. VPN or network changes making a previously-valid HOST unreachable. Misconfigured DNS for a custom hostname.
AI-assisted analysis of react/create-react-app@6254386531 (2026-08-12).
Data as JSON: /api/errors/9357170dec961da8.
Report an issue: GitHub.