Phoenix channel get user IP address

for me it’s inside the x_headers: [{"x-forwarded-for", "x.y.z.external-ip-here"}]. (in some networks you’ll see multiple IPs comma separated)

It matters if your app has a load balancer in front of it and in which way it’s configured, sometimes you have to explicitly configure it to forward the client’s IP address. So take caution you’re not only seeing internal IPs that belong to your load balancer/forwarder.

Here’s a cross reference to an earlier reply: Phoenix socket/channels security / IP identification

1 Like