Skip to content
← Back to Community
How do I obtain the IP address of a user in Flask?
Profile icon
ProgrammingMyLi

I currently use
request.remote_addr to get an IP Address but I keep getting 172.18.0.1

Is replit blocking this?

Answered by notGilbert [earned 5 cycles]
View Answer
Voters
Profile icon
ProgrammingMyLi
Comments
hotnewtop
Profile icon
notGilbert

Replit uses a proxy that messes with the request's IP address, so that's not possible

Profile icon
ProgrammingMyLi

@notGilbert
Thank you.

Profile icon
ProgrammingMyLi

@notGilbert
Do you know of any other way I can rate limit my API? Could I still obtain their User Agent?

Profile icon
notGilbert

@ProgrammingMyLi

maybe you could implement an api key system?

Profile icon
ProgrammingMyLi

@notGilbert
i can’t do it since its a website to submit forms and responses

Profile icon
notGilbert

@ProgrammingMyLi
user authentication? i guess that's the only way that's allowed on replit

Profile icon
Coder100

psst none of this stuff is allowed by tos

@notGilbert

Profile icon
28klotlucas2

You can use some javascript code to get the it, but getting the ip of a user with javascript is easily spoofable against tos!

Profile icon
Coder100

psst you can fix it by making a custom domain so it isn't restricted by replit

but this is against tos, so don't ever publicly release ips.

Profile icon
[deleted]

I mean like if you mess by creating the repl enviorment inside of a repl you could get it working without the proxy interfearing

Profile icon
ANDREWVOSS

@novaflippers
The proxy is likely running outside the VM, in which case that wouldn't work.

Profile icon
ANDREWVOSS

As far as I know, you can't collect IP's in replit. It's against the TOS anyway, so if you figure out how to do it you might get your repl removed.