is-reachable
Check if servers are reachable
Last updated 9 years ago by silverwind .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install is-reachable 
SYNC missed versions from official npm registry.

is-reachable

Check if servers are reachable

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

The Node.js version will do a TCP handshake with the target's port. It attempts to detect cases where a router redirects the request to itself.

The browser version is limited by the fact that browsers cannot connect to arbitrary ports. It only supports HTTP and HTTPS and the check relies on the /favicon.ico path being present.

Install

$ npm install is-reachable

Usage

const isReachable = require('is-reachable');

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

	console.log(await isReachable('google.com:443'));
	//=> 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, 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.

options

Type: object

timeout

Type: number
Default: 5000

Timeout in milliseconds after which a request is considered failed.

Node.js only

Related

  • is-online - Check if the internet connection is up

Maintainers

Current Tags

  • 5.2.1                                ...           latest (2 years ago)

20 Versions

  • 5.2.1                                ...           2 years ago
  • 5.2.0                                ...           3 years ago
  • 5.1.1                                ...           3 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.0                                ...           4 years ago
  • 4.0.0                                ...           5 years ago
  • 3.1.0                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.4.0                                ...           7 years ago
  • 2.3.3                                ...           7 years ago
  • 2.3.2                                ...           8 years ago
  • 2.3.1                                ...           8 years ago
  • 2.3.0                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.3.0                                ...           9 years ago
  • 1.2.0                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Downloads
Total 16
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE