0

I am working on nodeJS project in this project I want to get client IP address. For this I am using public IP package, I’m using the following code, and installed the package accordingly.

‘npm install --save public-ip

and following code

publicIp.v4().then(ip => {

});’

The above code is working fine locally, but when deployed on the server(AWS server), it’s giving the AWS server IP. Help me resolve the issue.

Eazy
  • 133
  • 11
kushal
  • 181
  • 14
  • request.connection.remoteAddress? – Nitin Dhomse Nov 14 '17 at 12:49
  • @NitinDhomse I tried this but not working on server – kushal Nov 14 '17 at 12:50
  • 2
    @kushalpawar are you sure you're using the correct tool here, this package will give you the _server_'s IP address. Are you looking for the _connecting client_ IP address? – James Nov 14 '17 at 12:51
  • @James I need client machine IP address, above code work fine locally , but not working on server. is there any configuration needed on server for this? – kushal Nov 14 '17 at 12:53
  • 1
    This is for sure not the right tool for getting the **client's** IP address. Description of the package: *Get **your** public IP address - very fast!* – qqilihq Nov 14 '17 at 12:56
  • are you using https? – amyloula Nov 14 '17 at 12:56
  • 2
    @kushalpawar *"work fine locally"* most likely because the you'll be testing on the same machine you're running the server.... You need to inspect the incoming web request for the client IP (as per the example from Nitin Dhomse) – James Nov 14 '17 at 12:56
  • @loulala yes i am using http – kushal Nov 14 '17 at 12:58
  • @James nodejs API called from mobile app , and i am getting correct ip of mobile, – kushal Nov 14 '17 at 12:59
  • 1
    Possible duplicate of [How to determine a user's IP address in node](https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node) – Veve Nov 14 '17 at 13:00
  • @kushalpawar let me guess, mobile app either running locally on an emulator or running off the same wifi network? – James Nov 14 '17 at 13:02
  • @James we have tested with mobile app using mobile own data , – kushal Nov 14 '17 at 13:05
  • @kushalpawar How is the mobile app able to access your local machine? – JLRishe Nov 14 '17 at 13:34

0 Answers0