Forums

how to get user IP address in Flask?

request.remote_addr always returns 10.190.154.117

It's a common occurence in cloud services: that's the address of the load-balancer that's forwarding requests to your web app. We make the load balancer set a couple of special headers on each request though, X-Real-IP and X-Forwarded-For.

So try something like this:

user_ip = request.headers['X-Real-IP']

thank you for your reply :)