IP address returning as IPV6 instead of IPV4

Hello all

This may seem trivial, but I can’t seem to figure out how to display the user’s ip address with IPV4 instead of IPV6.

I simply just have as:
var ip = req.ip

in my callback function.

1 Like

If the client connects to the IPv6 address of the server, then their ip is going to be an IPv6 address, and if they connect to the IPv4 address, then it will be IPv4. No exceptions. If you’re connecting to localhost, that usually resolves to ::1, which is why you’re seeing it that way.

Ideally, leave it as it is, because that’s correct behavior.

1 Like

When I try out with FCC’s sample project, it gives me IPv4 format though

1 Like

That’s because like most public websites, it’s listening on an IPv4 address, and every client connects to that. Your server has both IPv4 and IPv6 addresses (it at least has ::1 for localhost) so when you hit the IPv6 address, it gives you that as your connecting IP.

If it is localhost that’s giving you an IPv6 address back, try connecting to and notice how the client IP goes back to IPv4

Cool, thanks for the feedback.

So would this mean that if I deploy my project to heroku, would it display as IPv4?

Thank you so much for sharing such a good information about IPV4. I also found that we can 192.168.l.l change password