0

I have tried using this:

ip_address=str(request.META.get('HTTP_X_FORWARDED_FOR'))

But it always return None. Also I have tried this:

ip_address=request.META.get('CF-Connecting-IP', request.META.get('REMOTE_ADDR'))

But it always return 127.0.0.1. I need client side ip address, not the remote ip address. Any help would be appreciated. I need the ipv4 address like this.

Rajesh Samui
  • 167
  • 1
  • 2
  • 12
  • This could be useful `https://stackoverflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django` – mbieren Feb 27 '18 at 13:50
  • I did use this before. But it returns 127.0.0.1 – Rajesh Samui Feb 27 '18 at 14:18
  • 1
    Are you running your code on the local host? because https://stackoverflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django will give you the client ip.... – Gal Silberman Feb 27 '18 at 14:49
  • yes, I am running my code on local host. But I have checked on google cloud server and I got client side Ip address. Thanks. You are rignt "Gal" – Rajesh Samui Feb 28 '18 at 08:44

0 Answers0