title: How to get public IP address of client sending the request using Nodejs express?
body: <p>I want to get the public IP address of the client using Nodejs express. I searched for the question online which lead me to use this:</p>
  
  <pre><code>var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
      console.log(ip)
  </code></pre>
  
  <p>However, in my console I get</p>
  
  <blockquote>
    <p>::ffff:192.168.1.2</p>
  </blockquote>
  
  <p>which is my local IP address not the public IP address</p>