title: Consul service discovery issue with spring boot applications
body: <p>According to this blog <a href="https://spring.io/blog/2015/07/14/microservices-with-spring" rel="nofollow">https://spring.io/blog/2015/07/14/microservices-with-spring</a> which is based on eureka service discovery and where the service discovery is working properly.</p>
  
  <p>But when have switched to use Consul instead Eureka the service discovery is not working and getting this error:</p>
  
  <pre><code>java.lang.IllegalStateException: No instances available for ACCOUNTS-SERVICE
  at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:79)
  at org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor.intercept(LoadBalancerInterceptor.java:46) ...
  </code></pre>
  
  <p>UPDATED: After have fixed the previous error by providing the correct health-check endpoint (see the answer below), when deploying the services to Cloud Foundry with properly provided host and port of the Consul server in bootstrap.yml (Consul based PropertySource loaded during the 'bootstrap' phase):</p>
  
  <pre><code>---
  spring:
    profiles: cloud
    cloud:
      consul:
        host: &lt;consul host or ip&gt;
        port: 8500
  </code></pre>
  
  <p>Consul is registering the service, but with critical state (failing)! </p>
  
  <p>Would appreciate any help or guidance.</p>
  
  <p>Thanks</p>