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.
Feign is not able to resolve service name with IP address. E.g Feign trying to request http://registrationServices/api/registration-services/registrationId , where registrationServices is service registered with Eureka and name of Fiegn client .
I have also set eureka.instance.preferIpAddress=true in registration services and its reflecting in Eureka , but somehow Fiegn is not able to resolve it.