Forums

How to get client IP address for log (Flask)

Hi, I'm trying to record the IP address of the clients for logging purposes. I've tried request.remote_addr on Flask but its seems to be giving a PythonAnywhere related IP (i.e., 10.87.38.59). Is there anyway to get the actual client's IP on a free account using Flask? Thanks.

We set a couple of request headers (X-Forwarded-For and X-Real-IP), so try something like:

request.headers.get('X-Real-IP')