title: Ribbon with Spring Cloud and Eureka java.lang.IllegalStateException: No instances available for localhost
body: <p>I am using </p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-netflix&lt;/artifactId&gt;
    &lt;version&gt;1.2.3.RELEASE&lt;/version&gt;
    &lt;type&gt;pom&lt;/type&gt;
    &lt;scope&gt;import&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>My main class:</p>
  
  <pre><code>@SpringBootApplication
  //@Configuration
  @ComponentScan(basePackages = "com.mypackage")
  @EnableAutoConfiguration
  @EnableEurekaClient
  @EnableSwagger2
  public class App 
  {
    public static void main( String[] args )
    {
  
      SpringApplication.run(App.class, args);
    }
  
    @LoadBalanced
    @Bean(name="template")
    RestTemplate restTemplate() {
      return new RestTemplate();
    }
  }
  </code></pre>
  
  <p>My service calling:</p>
  
  <pre><code>@Autowired
  private RestTemplate template;
  
  ResponseEntity&lt;String&gt; avs = template.exchange("http://localhost:7075/xyz/json/authenticate",HttpMethod.POST ,request,String.class); 
  </code></pre>
  
  <p>It is throwing the following exception</p>
  
  <pre><code>java.lang.IllegalStateException: No instances available for localhost
      at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:90)
      at org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor$1.doWithRetry(RetryLoadBalancerInterceptor.java:60)
      at org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor$1.doWithRetry(RetryLoadBalancerInterceptor.java:48)
      at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:276)
      at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:157)
  </code></pre>