deltanovember deltanovember - 1 year ago 130
Node.js Question

How can I get the local IP address in Node.js?

I'm not referring to

But rather the one that other computers would use to access the machine e.g.

Answer Source

var os = require('os');

var interfaces = os.networkInterfaces();
var addresses = [];
for (var k in interfaces) {
    for (var k2 in interfaces[k]) {
        var address = interfaces[k][k2];
        if ( === 'IPv4' && !address.internal) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download