Socket
Socket
Sign inDemoInstall

is-reachable

Package Overview
Dependencies
39
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-reachable

Check if servers are reachable


Version published
Maintainers
2
Install size
2.19 MB
Created

Readme

Source

is-reachable Build Status

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:80'));
	//=> 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 a full URL like https://hostname, hostname:port or just hostname. When the protocol is missing from a target http is assumed.

Well-known protocols are supported (for example: ftp://, mysql://, redis:// and more).

options

Type: object

timeout

Type: number
Default: 5000

Timeout in milliseconds after which a request is considered failed.

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

Maintainers

License

MIT

Keywords

FAQs

Last updated on 20 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc