PROBLEM
When attempting use Feign to invoke a service through Eureka, the following exception occurs:-
MY-HOST-NAME executing GET http://donkey-kong-service/throw/barrels/10 feign.RetryableException: MY-HOST-NAME executing GET http://donkey-kong-service/throw/barrels/10 at feign.FeignException.errorExecuting(FeignException.java:84) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:113) ... Caused by: java.net.UnknownHostException: MY-HOST-NAME at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
SOLUTION
Go to the donkey-kong-service app and add the following line to the application.properties
:-
eureka.instance.prefer-ip-address=true
Now, when Feign tries to invoke the service, the IP address will be used instead of the OS’ reported hostname.