{"record":{"id":"9357170dec961da8","repo":"react/create-react-app","slug":"could-not-find-an-open-port-at-host-nnetwork-e","errorCode":null,"errorMessage":"Could not find an open port at ${host}.\\nNetwork error message: ${err.message}\\n","messagePattern":"Could not find an open port at (.+?)\\.\\\\nNetwork error message: (.+?)\\\\n","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dev-utils/WebpackDevServerUtils.js","lineNumber":428,"sourceCode":"                message +\n                  `${existingProcess ? ` Probably:\\n  ${existingProcess}` : ''}`\n              ) + '\\n\\nWould you like to run the app on another port instead?',\n            initial: true,\n          };\n          prompts(question).then(answer => {\n            if (answer.shouldChangePort) {\n              resolve(port);\n            } else {\n              resolve(null);\n            }\n          });\n        } else {\n          console.log(chalk.red(message));\n          resolve(null);\n        }\n      }),\n    err => {\n      throw new Error(\n        chalk.red(`Could not find an open port at ${chalk.bold(host)}.`) +\n          '\\n' +\n          ('Network error message: ' + err.message || err) +\n          '\\n'\n      );\n    }\n  );\n}\n\nmodule.exports = {\n  choosePort,\n  createCompiler,\n  prepareProxy,\n  prepareUrls,\n};\n","sourceCodeStart":410,"sourceCodeEnd":444,"githubUrl":"https://github.com/react/create-react-app/blob/6254386531d263688ccfa542d0e628fbc0de0b28/packages/react-dev-utils/WebpackDevServerUtils.js#L410-L444","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n// .env\nHOST=dev.local.example\n// after\n// .env\nHOST=127.0.0.1","handlingStrategy":"validation","validationCode":"const net = require('net');\nconst dns = require('dns').promises;\nasync function canReachHost(host) {\n  // loopback/ips are bindable; hostnames must resolve\n  if (net.isIP(host)) return true;\n  try { await dns.lookup(host); return true; } catch { return false; }\n}\n// before choosePort:\nconst host = process.env.HOST || '0.0.0.0';\nif (!(await canReachHost(host))) {\n  throw new Error(`HOST '${host}' is not reachable/bindable on this machine`);\n}","typeGuard":"const isBindableHost = (h) =>\n  h === 'localhost' || h === '0.0.0.0' || net.isIP(h) !== 0;","tryCatchPattern":"try {\n  const port = await choosePort(process.env.HOST || '0.0.0.0', 3000);\n  if (!port) process.exit(0);\n} catch (e) {\n  if (/Could not find an open port|Network error/.test(e.message)) {\n    console.error('HOST not reachable. Try HOST=127.0.0.1');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["network","port","dev-server","webpack","host"],"backgroundTag":null,"analyzedSha":"6254386531d263688ccfa542d0e628fbc0de0b28","analyzedAt":"2026-08-12T22:55:01.751Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}