require('dns').resolve('www.google.com', function(err) { if (err) { console.log("No connection"); } else { console.log("Connected"); } });