Check if the internet connection is up

Overview

is-online

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.

Install

$ npm install is-online

Usage

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

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

API

isOnline(options?)

options

Type: object

timeout

Type: number
Default: 5000

Milliseconds to wait for a server to respond.

ipVersion

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 icanhazip.com (or ipify.org as fallback) via HTTPS.
  • Query myip.opendns.com and o-o.myaddr.l.google.com 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.

Maintainers

Related

You might also like...

Open-source NFID SDK for Internet Identity, a blockchain authentication system for the Internet Computer.

Open-source NFID SDK for Internet Identity, a blockchain authentication system for the Internet Computer.

NFID-SDK is an open source software development kit that contains examples and packages for developers to integrate NFID into your application

Dec 23, 2022

Check ipo allotment result from CLI. [WIP for bulk check]

# Check your ipo allotment result via CLI Install node js and run these commands clone the repo cd checkipo-cli npm

Oct 12, 2022

A mobile web application to check the data on the total covid19 confirmed cases and deaths, check data for all countries with recorded cases.

This is a mobile web application to check the data on the total covid19 confirmed cases and deaths, check data for all countries with recorded cases. It also has a details page to check for the statistics for each region/state if available.

Jul 30, 2022

Modular Redis connection and PUBSUB subscription manager for node. Easily extendable. Built for performance, powered by ioredis.

RediBox Redis connection and PUBSUB subscription manager for node. Built for performance, powered by ioredis (for now). Maintained by TeamFA. What is

Dec 15, 2022

Very minimalistic boilerplate to start most Typescript Express projects. Includes Mongodb connection via Mongoose with a sample post model.

Very minimalistic boilerplate to start most Typescript Express projects. Includes Mongodb connection via Mongoose with a sample post model.

Minimalist express-typescript-boilerplate Available Scripts - `tsc' - builds the tsc project to the dist folder - `build` - cleans the previous build

Dec 13, 2022

💻 ssher.vim is interacting remote machines(only linux) through ssh connection

💻 ssher.vim is interacting remote machines(only linux) through ssh connection

Feb 21, 2022

CyberGraph is a 3D-graph based, user based social connection explorer

CyberGraph is a 3D-graph based, user based social connection explorer

CyberGraph is a 3D-graph based, user based social connection explorer. It has some cool features like 3d node graph, dynamic loading bar, immersive user experience, cyber mode(10-hops friendship network display) and focus mode(aggregated connection display).

Nov 25, 2022

Run SPARQL/SQL queries directly on Virtuoso database with connection pool support.

🔗 virtuoso-connector Package that allows you to create a direct connection to the Virtuoso database and run queries on it. Connection can be used to

Nov 15, 2022

The user interface of the Restreamer for the connection to the Core application.

Restreamer-UI The user interface of the Restreamer for the connection to the Core application. React Material-UI (MUI) Development For the Restreamer

Dec 21, 2022

A remake of the famous Google Chrome Dinosaur game that comes-up when we're out of connection.

A remake of the famous Google Chrome Dinosaur game that comes-up when we're out of connection.

Dino Game Preview: Project: This is a remake of the classic "easter egg" T-Rex game that we can play on Google Chrome when we're out of connection. Ho

Nov 9, 2022

A clean-looking, secure, MySQL/MariaDB remote connection terminal made in NodeJS

A clean-looking, secure, MySQL/MariaDB remote connection terminal made in NodeJS

NodeJS MySQL/MariaDB Terminal NodeJS MySQL/MariaDB Terminal is a remote terminal for MySQL/MariaDB databases, which works in the same way as the offic

Jun 24, 2022

An abstraction layer on top of @replit/crosis that makes Repl connection management and operations so easy, a Furret could do it! 🎉

An abstraction layer on top of @replit/crosis that makes Repl connection management and operations so easy, a Furret could do it! 🎉

Crosis4Furrets An abstraction layer on top of @replit/crosis that makes Repl connection management and operations so easy, a Furret could do it! 🎉 In

Dec 29, 2022

NestJS implementation of client and strategy hasn't enough features for work with RabbitMQ so i developed this one (basically, just a wrapper for amqp-connection-manager)

NestJS RabbitMQ Client and strategy NestJS implementation of client and strategy hasn't enough features for work with RabbitMQ so i developed this one

Sep 6, 2022

to choose the best one of Gcore‘IPs for connection with lowest latency.

GcoreCDNIPSelector to choose the best IP from Gcore-CDN to reach the lowest latency and stable connections. Background Gcore's CDN provide a smooth ex

Nov 5, 2022

A TypeScript/JavaScript library for working with ASN, IPv4, and IPv6 numbers. It provides representations of these internet protocol numbers with the ability to perform various IP related operations like parsing, validating etc. on them

A TypeScript/JavaScript library for working with ASN, IPv4, and IPv6 numbers. It provides representations of these internet protocol numbers with the ability to perform various IP related operations like parsing, validating etc. on them

ip-num ip-num is a TypeScript library for working with IPv4, IPv6 and ASN numbers. It provides representations of these internet protocol numbers with

Dec 8, 2022

selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8.

Selectivizr CSS3 selectors for IE 6-8 selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explor

Dec 18, 2022

A behavior for Internet Explorer allowing it to recognize and render various CSS3 box decoration properties

============================ ====== PIE ====== ==========

Dec 26, 2022

Only 90's kids remember... well not really, but these beloved effects that would follow your mouse around will always be classic reminders of the old, beloved internet.

90's Cursor Effects "Knowing the codes" used to be all the rage, I want to bring a few back. A repo of the old effects that inspired creativity and th

Jan 9, 2023

Plug is a browser extension for users of the Internet Computer that allows you to access your ICP, Cycles, and other tokens as well as log into IC apps with one click.

Plug is a browser extension for users of the Internet Computer that allows you to access your ICP, Cycles, and other tokens as well as log into IC apps with one click.

Plug Introduction Welcome to Plug! An Internet Computer crypto wallet and authentication provider as a browser extension. Find our latest version in t

Dec 23, 2022
Releases(v10.0.0)
  • v10.0.0(Jun 6, 2022)

  • v9.0.1(Jun 12, 2021)

  • v9.0.0(Oct 25, 2020)

    Breaking

    • Require Node.js 10 88e5b29
    • Rename version option to ipVersion and make it a number (#79) 61d5046

    Breaking for TypeScript users

    • Only use a CommonJS export for the TypeScript definition (reason) You need to change import isOnline from 'is-online'; to import isOnline = require('is-online');

    https://github.com/sindresorhus/is-online/compare/v8.5.1...v9.0.0

    Source code(tar.gz)
    Source code(zip)
  • v8.5.1(Oct 18, 2020)

  • v8.5.0(Oct 11, 2020)

  • v8.4.0(Jun 2, 2020)

  • v8.3.1(May 4, 2020)

  • v8.3.0(Apr 6, 2020)

  • v8.2.2(Apr 4, 2020)

    • Fix UV pool overflow and cancel outstanding HTTP requests on DNS success (#69) 0349077

    https://github.com/sindresorhus/is-online/compare/v8.2.1...v8.2.2

    Source code(tar.gz)
    Source code(zip)
  • v8.2.1(Nov 26, 2019)

  • v8.2.0(Apr 4, 2019)

    • Refactor TypeScript definition to CommonJS compatible export (#60) c221f36

    https://github.com/sindresorhus/is-online/compare/v8.1.0...v8.2.0

    Source code(tar.gz)
    Source code(zip)
  • v8.1.0(Mar 3, 2019)

    • Add TypeScript definition (#58) fe5cedb
    • Update dependencies (#58) fe5cedb

    https://github.com/sindresorhus/is-online/compare/v8.0.0...v8.1.0

    Source code(tar.gz)
    Source code(zip)
  • v8.0.0(Nov 30, 2018)

Owner
Sindre Sorhus
Full-Time Open-Sourcerer. Wants more empathy & kindness in open source. Focuses on Swift & JavaScript. Makes macOS apps, CLI tools, npm packages. Likes unicorns
Sindre Sorhus
Check ipo allotment result from CLI. [WIP for bulk check]

# Check your ipo allotment result via CLI Install node js and run these commands > clone the repo > cd checkipo-cli > npm

Yaman Sarabariya 4 Oct 12, 2022
Check NPM package licenses

NPM License Checker As of v17.0.0 the failOn and onlyAllow arguments take semicolons as delimeters instead of commas. Some license names contain comma

Dav Glass 1.5k Dec 29, 2022
Check whether a website is up or down

is-up Check whether a website is up or down using the isitup.org API Install $ npm install is-up Usage const isUp = require('is-up'); (async () => {

Sindre Sorhus 384 Dec 7, 2022
Check whether a package or organization name is available on npm

npm-name Check whether a package or organization name is available on npm Install $ npm install npm-name Usage import npmName from 'npm-name'; // Ch

Sindre Sorhus 157 Nov 13, 2022
NodeJS built CLI, allows to spell check in 14 languages, get Coleman-Liau Index and build hash Pyramids

Magic CLI ?? ?? NodeJS built CLI, allows to spell check in 14 languages, get Coleman-Liau Index and build hash Pyramids Installing Install dependencie

Lucas 3 Sep 27, 2022
⚡️The Fullstack React Framework — built on Next.js

The Fullstack React Framework "Zero-API" Data Layer — Built on Next.js — Inspired by Ruby on Rails Read the Documentation “Zero-API” data layer lets y

⚡️Blitz 12.5k Jan 4, 2023
Test your internet connection speed and ping using speedtest.net from the CLI

speed-test Test your internet connection speed and ping using speedtest.net from the CLI Install Ensure you have Node.js version 8+ installed. Then ru

Sindre Sorhus 3.8k Jan 7, 2023
Pinging.net - Monitor Your Internet Connection

Pinging.net Pinging.net quickly determines if you are online by running multiple tests. It then continues to monitor your connection via repeated test

Ben Hansen 41 Nov 27, 2022
Check in, check the weather, Check out.

☀️ Just-Weather ??️ Hi, Welcome! Just Weather is a Web App designed for Fast Real-Time Weather queries in combination with well Thought Out Visual Des

Miguel Ángel 6 Aug 7, 2022
DNS-Blocklists: For a better internet - keep the internet clean!

DNS Blocklists - For a better internet! Multi - Cleans the Internet and protects your privacy! An all in one blocklist based on the OISD blocklist, ba

Gerd 280 Jan 2, 2023