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

191
Views
How can I detect the IP address of a browser in Express?

This is not a duplicate of this SO post. That method does not work for me. The output is shown below. I am running a local node server on my MacBook and using chrome to test. I get this output.

undefined | ::1

I am connected to the network and can verify that my browser does have an IP address using zshell on Mac which is actually ( I have hidden the last 3 digits for this post):

100.64.98.xxx

However from my server I do not get a reading.

// derived from SO Post above
function getIP(app) {
  app.use((req, res, next) => {
    const ip1 = req.headers['x-forwarded-for'];
    const ip2 = req.socket.remoteAddress;
    const ip =  ip1 || ip2;

    // undefined | ::1
    console.log(ip1 + ' | ' + ip2);
    next();
  });
}

Sometimes the ordering of middleware seems to effect things, and I'm not sure if this might be the case here.

about 4 years ago · Juan Pablo Isaza
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!