Net-ping: Operation not permitted


I’m trying to use the net-ping package to create a webservice that will ping a host and give me the result. I get an “Operation not permitted” error. Is this just not allowed?

 Error: Operation not permitted
     at Error (native)
     at new Socket (/app/node_modules/raw-socket/index.js:47:14)
     at Object.exports.createSocket (/app/node_modules/raw-socket/index.js:202:9)
     at Session.getSocket (/app/node_modules/net-ping/index.js:147:20)
     at new Session (/app/node_modules/net-ping/index.js:101:7)
     at Object.exports.createSession (/app/node_modules/net-ping/index.js:545:9)


Net-ping uses raw sockets that require root privileges to run, resulting in the error you’re seeing. Would something like request also work for your use-case or is it specifically pinging you need?


Thanks. While it would be nice to use ICMP ping, for this particular case request will work since there’s a web server exposed that I can check to see if the host is alive.