Load balancer does not have available server for client

The problem is that your service doesn't know the host of requested service. If you are using Eureka, put this line on your .properties file:

eureka.client.fetchRegistry=true

OR .yml file:

eureka:
    client:
        fetch-registry: true

It'll make your service talk with Eureka and discover the host of the requested service.


I nearly wasted 2 hours to find the root cause. I mistakenly imported EnableEurekaClient in client application, which was the root cause for the issue. I finally resolved this issue by removing the import. To my surprise @EnableDiscoveryClient does not require the below dependency. But if you are using Eureka Naming server than this has to be used.

   <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        <version>2.0.0.RELEASE</version>
    </dependency>

If your Spring Cloud set up does not support specifying the servers in application.properties/application.yml, you have to configure the services URL in a Configuration class.

Pls, note the warning message in my application.properties [Spring Boot v2.0.0RELEASE, spring-cloud-starter-feign & spring-cloud-starter-ribbon v 1.4.3.RELEASE]

enter image description here

So what I did was to write a Configuration class as follows:

@Configuration
class LocalRibbonClientConfiguration {
    @Bean
    public ServerList<Server> ribbonServerList() {
        // return new ConfigurationBasedServerList();
        StaticServerList<Server> staticServerList = new StaticServerList<>((new Server("localhost", 8001)),
                new Server("localhost", 8000));
        return staticServerList;
    }
}

Then, configured the Spring Boot Application to use this configuration as follows:

@SpringBootApplication
@EnableFeignClients("my-package.currencyconversionservice")
@RibbonClient(name = "currency-conversion-service", configuration = LocalRibbonClientConfiguration.class)
public class CurrencyConversionServiceApplication {
 // nothing new here...
}

No need to change the Feign Proxy class. Posting just for this post to be served as a complete solution to the problem:

@FeignClient(name="currency-exchange-service")
@RibbonClient(name="currency-exchange-service")
public interface CurrencyExchangeServiceProxy {
    @GetMapping("/currency-exchange/from/{from}/to/{to}")
    public CurrencyConversionBean retrieveExchangeValue(@PathVariable("from") String from, @PathVariable("to") String to);
}

That's all. The problem was fixed.


After doing research, and with help of @Bloodysock, I found that I was missing registration of remote server in 'client-app' micro-service. The document is at Spring Cloud Netflix.

I used Ribbon without Eureka with configuration in application.yml in 'client-app' micro-service as:

movie-api:
  ribbon:
    listOfServers: http://localhost:8090