HttpServletRequest.getRemoteAddr() in Tomcat returns IPv6 formatted IP address
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. try adding this parameter -Djava.net.preferIPv4Stack=true to your tomcat startup commandline. when you use localhost/xxx, your browser first have to find the mapped address for the name