HttpServletRequest.getRemoteAddr() in Tomcat returns IPv6 formatted IP address
10,829
try adding this parameter -Djava.net.preferIPv4Stack=true
to your tomcat startup commandline.
Author by
davorp
Software engineer with interest in backend development, high-availability, distributed systems, disruptive business. Currently working on real-time data analytics with Kafka, Redis and druid.io. OBDII enthusiast. IoT enthusiast. Cinephile. Windsurfer. Davor @ Careers Davor @ LinkedIn
Updated on June 04, 2022Comments
-
davorp almost 2 years
HttpServletRequest.getRemoteAddr() in Tomcat returns IPv6 formatted IP address, but I would like to configure it that returns IPv4.
I access the servlet via 'localhost'. If I access it via '127.0.0.1' then returns IPv4 formatted IP address (see this answer).
Environment:
- Windows 7 x64
- Tomcat 6.0.35-windows-x64
My LAN connection properties: IPv6 is checked off, but it doesn't work neither if I check it on.