Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
Node.js get a computer network ip format usable in an external LAN post request

The code below is built to fetch the network ip of a computer in a LAN network.

I need to identify the computer's network ip format like '192.1.xx.x.x59' that can be usable when making an external LAN post request.

The problem is the code keeps returning '0.0.0.0' as the network ip.

Could you please help me spot the problem with this code.

Thanks in advance!


function getIPAddress() {
    var interfaces = require('os').networkInterfaces();
    for (var devName in interfaces) {
      var iface = interfaces[devName];
  
      for (var i = 0; i < iface.length; i++) {
        var alias = iface[i];
        if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal)
          return alias.address;
      }
    }
    return '0.0.0.0';
}

console.log(getIPAddress());

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According to your code, I think you didn't connect to any network wifi or something. So, returning 0.0.0.0

you can see by logging interfaces

var interfaces = require('os').networkInterfaces();

console.log(interfaces);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!