title: Node.js - Recreating navigator.onLine
body: <p>I have a Node.js app. I am trying to write a utility app to do some network detection. I'm creating this app just to learn more about Node.</p>
  
  <p>In this app, I want to see if a) my computer is online and b) if it can reach the internet. If I was doing this in the browser, I could use <code>navigator.onLine</code>, then attempt to reach a website. However, that's not an option in Node.</p>
  
  <p>I looked at the <a href="https://nodejs.org/api/os.html#os_os_networkinterfaces" rel="nofollow noreferrer">OS module's networkInterfaces method</a>, however, that doesn't seem to have what I need. For example, if you go to a Starbucks, you can be "online" but not actually reach the internet until you agree to the terms of service for their network. I've been testing this scenario by toggling airplane mode on my machine. Whether Airplane Mode is on or off, the <code>networkInterfaces</code> method returns the same thing.</p>
  
  <p>How can I recreate the <code>navigator.onLine</code> functionality in Node?</p>