Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the IP address of the request to a Heroku app?

Heroku has a routing system to forward requests to the dynos. My application needs to know from where the request came, but it always gets random addresses in a network, probably Heroku's internals.

And I see that in the logs, it (Heroku's router) gets my IP address and forwards the request. Is there a way to get the actual IP address of a request?

My application is written in Python, using Flask

like image 594
illright Avatar asked Oct 27 '25 11:10

illright


1 Answers

Checking Flask's documentation on filtering headers etc., I found that:

request.headers['X-Forwarded-For']

is where you'll get the client's real IP address.


From a deleted comment by OP, this article provides a safer solution.

like image 146
hjpotter92 Avatar answered Oct 30 '25 01:10

hjpotter92