Checks if a given hypermedia link is working or broken (2xx).
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status Greenkeeper badge

Checks if a given hypermedia link is working or broken (2xx).

Tries a HEAD request first because it's faster. If that fails, tries a GET request and aborts it as soon as we got the response headers. If the URL is unreachable, optionally checks if you are offline to avoid returning false negatives.


$ npm install is-link-working


isLinkWorking(url, options) -> Promise

const isLinkWorking = require('is-link-working');

.then((working) => console.log('working', working))
.catch((err) => console.log('err while checking', err));

Available options:

  • checkConnectivity - True to check internet connectivity if the request fails because of a network error (defaults to false)
  • followRedirect - Defines if redirect responses should be followed automatically (defaults to true)
  • timeout - Milliseconds to wait for a server to send response headers before aborting request with ETIMEDOUT error (defaults to 10000)
  • retries - Number of request retries when network errors happens, see got retries option for more information (defaults to 3)
  • agent - The agent to use, see (defaults to null)

Connectivity status (online/offline) is made with is-online and its result is cached for 5000 ms to avoid calling it too many times. You may tweak that if you want:

isLinkWorking.connectivityCacheDuration = 0;  // No cache


$ npm test
$ npm test-cov to get coverage report


Released under the MIT License.