Skip to content Skip to sidebar Skip to footer

Localhost Vs 127.0.0.1 In Spring Framework

I am attempting to connect a spring rest service to a client which is an android device. I have followed this tutorial on creating my service: https://spring.io/guides/gs/rest-serv

Solution 1:

This could be because Java 7+ is using IPv6 as the default instead of IPv4. Thus localhost resolves into :::1 instead of 127.0.0.1.

Try the following:

Just pass -Djava.net.preferIPv4Stack=true to java VM options.

If this works you can make it permanent by setting _JAVA_OPTIONS on Linux:

export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"

You can place the above line inside /etc/profile or /etc/profile.d/java.sh (by creating the file java.sh)

Post a Comment for "Localhost Vs 127.0.0.1 In Spring Framework"