{"record":{"id":"1e760dd94973ce06","repo":"quasarframework/quasar","slug":"error-network-port-not-avail","errorCode":"ERROR_NETWORK_PORT_NOT_AVAIL","errorMessage":"ERROR_NETWORK_PORT_NOT_AVAIL","messagePattern":"ERROR_NETWORK_PORT_NOT_AVAIL","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app-vite/lib/utils/net.js","lineNumber":50,"sourceCode":"        list.push(networkAddress.address)\n      }\n    }\n  }\n\n  return list\n}\n\nexport async function findClosestOpenPort(port, host) {\n  let portProposal = port\n\n  do {\n    if (await isPortAvailable(portProposal, host)) {\n      return portProposal\n    }\n    portProposal++\n  } while (portProposal < 65_535)\n\n  throw new Error('ERROR_NETWORK_PORT_NOT_AVAIL')\n}\n\nexport function isPortAvailable(port, host) {\n  const { promise, resolve, reject } = Promise.withResolvers()\n\n  const tester = net\n    .createServer()\n    .once('error', err => {\n      if (err.code === 'EADDRNOTAVAIL') {\n        reject(new Error('ERROR_NETWORK_ADDRESS_NOT_AVAIL'))\n      } else if (err.code === 'EADDRINUSE') {\n        resolve(false) // host/port in use\n      } else {\n        reject(err)\n      }\n    })\n    .once('listening', () => {\n      tester","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/app-vite/lib/utils/net.js#L32-L68","documentation":"findClosestOpenPort scans upward from the requested port to 65535 looking for a free port on the given host and throws ERROR_NETWORK_PORT_NOT_AVAIL when the entire remaining port range is exhausted. The dev server infrastructure calls it via openPort/#computeConfig to pick a port for the dev server, so this failure means no usable TCP port could be bound.","triggerScenarios":"Calling openPort/findClosestOpenPort with a starting portProposal such that every port from it through 65535 fails isPortAvailable (already bound, permission-restricted, or otherwise unbindable) on the target host.","commonSituations":"Running many dev servers simultaneously on one machine exhausting ephemeral/high ports; a misconfigured host string (e.g. wrong interface) making every bind fail; containers/CI with restricted networking; a port-scan-happy firewall or a leaked process holding thousands of sockets.","solutions":["Check what is consuming ports with 'ss -ltn' or 'lsof -i -P -n | grep LISTEN' and kill leaked/stale processes","Retry on a fresh machine/container restart to release ephemeral sockets","Verify the host argument matches a real local interface (localhost/127.0.0.1 or the intended IP)","Lower the starting port (e.g. 9000 instead of 64000) so the scan has more room before 65535","Inspect container/CI network limits (ulimit, sysctl net.ipv4.ip_local_port_range)"],"exampleFix":"// before\nconst port = await openPort({ port: 65000, host: '0.0.0.0' }) // scans to 65535 quickly\n// after\nconst port = await openPort({ port: 9000, host: 'localhost' })","handlingStrategy":"retry","validationCode":"const net = require('node:net')\nasync function portFree(port, host = 'localhost') {\n  return new Promise(res => {\n    const s = net.createServer()\n    s.once('error', () => res(false))\n    s.once('listening', () => s.close(() => res(true)))\n    s.listen(port, host)\n  })\n}\nif (!(await portFree(9000))) console.warn('port 9000 busy; pick another start port')","typeGuard":null,"tryCatchPattern":"try {\n  port = await openPort({ port, host })\n} catch (err) {\n  if (err.message === 'ERROR_NETWORK_PORT_NOT_AVAIL') {\n    // inspect listeners / restart network stack / pick another interface\n  } else throw err\n}","preventionTips":["Start scans from a low, rarely-used base port (e.g. 9000)","Monitor listening sockets in CI to catch port leaks","Pin hosts explicitly instead of relying on default interfaces","Restart containers/machines with high uptime where ephemeral ports may be exhausted"],"tags":["network","port","dev-server"],"backgroundTag":"no-available-port","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}