# is-reachable

> Check if servers are reachable

Latest version **6.1.0** (published 2026-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-reachable
pnpm add is-reachable
yarn add is-reachable
bun add is-reachable
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.1.0 |
| Published | 2026-02-02 |
| First published | 2015-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 3 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 383 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | browser, online, offline, network, connected, connectivity, internet, is, has, detect, reachable, reachability, server, host, accessible, socket |

## Links

- npm: https://www.npmjs.com/package/is-reachable
- Repository: https://github.com/sindresorhus/is-reachable
- Homepage: https://github.com/sindresorhus/is-reachable#readme
- Issues: https://github.com/sindresorhus/is-reachable/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/is-reachable

## Dependencies (3)

- [fetch-extras](https://npm.io/package/fetch-extras.md) ^1.0.0
- [prepend-http](https://npm.io/package/prepend-http.md) ^4.0.0
- [is-port-reachable](https://npm.io/package/is-port-reachable.md) ^4.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 6.1.0 (latest) — 2026-02-02
- 6.0.0 — 2025-09-11
- 5.2.1 — 2022-06-15
- 5.2.0 — 2022-05-05
- 5.1.1 — 2021-11-24
- 5.1.0 — 2021-09-05
- 5.0.0 — 2020-10-17
- 4.0.0 — 2019-09-23
- 3.1.0 — 2019-04-20
- 3.0.0 — 2018-11-30
- 2.4.0 — 2018-01-30
- 2.3.3 — 2017-07-11
- 2.3.2 — 2017-02-08
- 2.3.1 — 2017-02-08
- 2.3.0 — 2017-02-08
- … 7 more at https://npm.io/package/is-reachable/versions

## README

# is-reachable

> Check if servers are reachable

Works in Node.js and the browser *(with a bundler)*.

The 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.

The 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`).

> [!IMPORTANT]
> 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.

## Install

```sh
npm install is-reachable
```

## Usage

```js
import isReachable from 'is-reachable';

console.log(await isReachable('sindresorhus.com'));
//=> true

console.log(await isReachable('google.com:443'));
//=> true

// With timeout
console.log(await isReachable('sindresorhus.com', {
	signal: AbortSignal.timeout(3000)
}));
//=> true
```

## API

### isReachable(targets, options?)

Returns a `Promise<boolean>` which is `true` if any of the `targets` are reachable.

#### targets

Type: `string | string[]`

One 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.

#### options

Type: `object`

##### signal

Type: `AbortSignal`

An `AbortSignal` to cancel the requests.

You can use `AbortSignal.timeout()` to create a signal that automatically aborts after a specified time:

```js
await isReachable('sindresorhus.com', {
	signal: AbortSignal.timeout(3000)
});
```

Or combine multiple signals using `AbortSignal.any()`:

```js
const controller = new AbortController();
const timeoutSignal = AbortSignal.timeout(5000);

await isReachable('example.com', {
	signal: AbortSignal.any([controller.signal, timeoutSignal])
});
```

##### requireHttpSuccess

Type: `boolean`\
Default: `false`

Only consider the server reachable if it returns a successful HTTP status code (200-299).

When `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".

When `true`, only successful HTTP responses (2xx status codes) are considered reachable, which is useful for application health checks.

## Related

- [is-online](https://github.com/sindresorhus/is-online) - Check if the internet connection is up

## Maintainers

- [Sindre Sorhus](https://github.com/sindresorhus)
- [silverwind](https://github.com/silverwind)

---
_Source: https://npm.io/package/is-reachable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
