Awesome Open Source
Awesome Open Source


Check if the internet connection is up

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

In the browser you have navigator.onLine, but it's useless as it only tells you if there's a local connection, and not whether the internet is accessible.


$ npm install is-online


const isOnline = require('is-online');

(async () => {
	console.log(await isOnline());
	//=> true




Type: object


Type: number
Default: 5000

Milliseconds to wait for a server to respond.


Type: number
Values: 4 | 6
Default: 4

Internet Protocol version to use. This is an advanced option that is usually not necessary to be set, but it can prove useful to specifically assert IPv6 connectivity.

How it works

The following checks are run in parallel:

  • Retrieve (or as fallback) via HTTPS.
  • Query and DNS entries. (Node.js only)
  • Retrieve Apple's Captive Portal test page (this is what iOS does). (Node.js only)

When any check succeeds, the returned Promise is resolved to true.

Proxy support

To make it work through proxies, you need to set up global-agent.



Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
javascript (68,063
nodejs (3,635
network (451
browser (432
internet (57
online (56
ping (48
detect (25
connectivity (15

Find Open Source By Browsing 7,000 Topics Across 59 Categories