{"name":"is-reachable","version":"6.0.0","keywords":["browser","online","offline","network","connected","connectivity","internet","is","has","detect","reachable","reachability","server","host","accessible","socket"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"is-reachable@6.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/is-reachable#readme","bugs":{"url":"https://github.com/sindresorhus/is-reachable/issues"},"dist":{"shasum":"fc1cfe44767198ab0a0e7c0a1998de360e0643ce","tarball":"http://registry-npm.ywwl.com/is-reachable/download/is-reachable-6.0.0.tgz","fileCount":6,"integrity":"sha512-WIYoYDplil2eVHkfxKUWcekTDU1sbArhvo3dOXbH+prjsYXKw8t1nIBUWnIVmvGYRx+P4qtXxO9u33SLP9+BdQ==","signatures":[{"sig":"MEUCIQD3LpNh4sNzBgGxG4tpHPcppb9PNm3l7msUzv4y/m/elwIge96Eg5DT/o6OqieEmpNeJ9wCmUYBKa0ssX1VgCpaEw4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13777,"size":4692,"noattachment":false,"key":"/is-reachable/-/is-reachable-6.0.0.tgz"},"type":"module","types":"./index.d.ts","engines":{"node":">=20"},"exports":{".":{"node":"./index.js","types":"./index.d.ts","browser":"./browser.js"}},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"bc6d1c3ae9cb37496d0cacae4df7259a22fb1901","scripts":{"test":"xo && node --test test.js"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/is-reachable.git","type":"git"},"_npmVersion":"10.9.2","description":"Check if servers are reachable","directories":{},"sideEffects":false,"_nodeVersion":"20.19.1","dependencies":{"router-ips":"^2.0.0","fetch-extras":"^1.0.0","prepend-http":"^4.0.0","is-port-reachable":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^1.2.2"},"_npmOperationalInternal":{"tmp":"tmp/is-reachable_6.0.0_1757592290636_0.5732423847138266","host":"s3://npm-registry-packages-npm-production"},"readme":"# is-reachable\n\n> Check if servers are reachable\n\nWorks in Node.js and the browser *(with a bundler)*.\n\nThe Node.js version uses HTTP HEAD/GET requests for HTTP(S) URLs and TCP connections for other ports. For HTTP(S), it tries HEAD requests first (for better performance and bandwidth efficiency), falling back to GET requests if HEAD is not supported.\n\nThe browser version is limited by the fact that browsers cannot connect to arbitrary ports. It only supports HTTP and HTTPS and tries to load common favicon paths (`/favicon.ico`, `/favicon.png`, `/favicon.svg`, `/apple-touch-icon.png`, `/apple-touch-icon-precomposed.png`) to determine reachability. The browser version does not support the `requireHttpSuccess` option and will only return `true` if the favicon files load successfully (equivalent to `requireHttpSuccess: true`).\n\n> [!IMPORTANT]\n> By default, any HTTP response (including 404, 401, 403, 500, etc.) is considered “reachable” since it proves the server is responding. This aligns with the network-level definition of reachability. Use the `requireHttpSuccess` option if you need to check for successful responses only.\n\n## Install\n\n```sh\nnpm install is-reachable\n```\n\n## Usage\n\n```js\nimport isReachable from 'is-reachable';\n\nconsole.log(await isReachable('sindresorhus.com'));\n//=> true\n\nconsole.log(await isReachable('google.com:443'));\n//=> true\n\n// With timeout\nconsole.log(await isReachable('sindresorhus.com', {\n\tsignal: AbortSignal.timeout(3000)\n}));\n//=> true\n```\n\n## API\n\n### isReachable(targets, options?)\n\nReturns a `Promise<boolean>` which is `true` if any of the `targets` are reachable.\n\n#### targets\n\nType: `string | string[]`\n\nOne or more targets to check. Can either be `hostname:port`, an IP address like `1.2.3.4` or `1.2.3.4:port`, a URL like `https://hostname:port`, or even just `hostname`. `port` must be specified if protocol is not `http:` or `https:` and defaults to `443`. Protocols other than `http:` and `https:` are not supported. Bare IP addresses default to HTTP.\n\n#### options\n\nType: `object`\n\n##### signal\n\nType: `AbortSignal`\n\nAn `AbortSignal` to cancel the requests.\n\nYou can use `AbortSignal.timeout()` to create a signal that automatically aborts after a specified time:\n\n```js\nawait isReachable('sindresorhus.com', {\n\tsignal: AbortSignal.timeout(3000)\n});\n```\n\nOr combine multiple signals using `AbortSignal.any()`:\n\n```js\nconst controller = new AbortController();\nconst timeoutSignal = AbortSignal.timeout(5000);\n\nawait isReachable('example.com', {\n\tsignal: AbortSignal.any([controller.signal, timeoutSignal])\n});\n```\n\n##### requireHttpSuccess\n\nType: `boolean`\\\nDefault: `false`\n\nOnly consider the server reachable if it returns a successful HTTP status code (200-299).\n\nWhen `false` (default), any HTTP response (including 4xx and 5xx) is considered reachable, as it proves the server is responding. This aligns with the network-level definition of \"reachability\".\n\nWhen `true`, only successful HTTP responses (2xx status codes) are considered reachable, which is useful for application health checks.\n\n## Related\n\n- [is-online](https://github.com/sindresorhus/is-online) - Check if the internet connection is up\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [silverwind](https://github.com/silverwind)\n","publish_time":1757592290819,"_cnpm_publish_time":1757592290819,"dist-tags":{"latest":"6.1.0"}}