Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda