title: Eureka Peer awareness example not working
body: <p>I am facing problem while running Eureka server example to understand peer awareness concept. 
  I have following Eureka service:</p>
  
  <pre><code>package com.micro.eurekaserver;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
  
  @SpringBootApplication
  @EnableDiscoveryClient
  @EnableEurekaServer
  public class EurekaServerMicroServiceApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(EurekaServerMicroServiceApplication.class, args);
      }
  }
  </code></pre>
  
  <p><strong>application.yml</strong></p>
  
  <pre><code> ---
  spring:
    profiles: peer1
  server:
    port: 8761
  eureka:
    instance:
      hostname: peer1
    client:
      serviceUrl:
        defaultZone: http://peer2:8762/eureka/
  
  ---
  spring:
    profiles: peer2
  server:
    port: 8762
  eureka:
    instance:
      hostname: peer2
    client:
      serviceUrl:
        defaultZone: http://peer1:8761/eureka/
  </code></pre>
  
  <p><strong>bootstrap.yml</strong></p>
  
  <pre><code>spring:
    application:
      name: eureka
  </code></pre>
  
  <p><strong>etc/hosts</strong></p>
  
  <pre><code>127.0.0.1   peer1
  127.0.0.1   peer2
  localhost   peer1
  localhost   peer2
  </code></pre>
  
  <p>When I am running this Eureka service, I am continuously getting following exception:</p>
  
  <p>2016-03-26 12:19:57.708 ERROR 4940 --- [           main] </p>
  
  <pre><code>com.netflix.discovery.DiscoveryClient    : Can't contact any eureka nodes - possibly a security group issue?
  
  com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.jar:1.19]
      at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.jar:1.19]
      at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.3.7.jar:1.3.7]
      at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.jar:1.19]
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.jar:1.19]
      at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.jar:1.19]
      at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) ~[jersey-client-1.19.jar:1.19]
      at com.netflix.discovery.DiscoveryClient.getUrl(DiscoveryClient.java:1802) [eureka-client-1.3.7.jar:1.3.7]
      at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1546) [eureka-client-1.3.7.jar:1.3.7]
      at com.netflix.discovery.DiscoveryClient.makeRemoteCallWithFollowRedirect(DiscoveryClient.java:1460) [eureka-client-1.3.7.jar:1.3.7]
      at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1443) [eureka-client-1.3.7.jar:1.3.7]
      at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1394) [eureka-client-1.3.7.jar:1.3.7]
  
  2016-03-26 12:23:09.963 ERROR 4940 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EUREKA/KHUJEMA-PC:eureka - was unable to send heartbeat!
  
  com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.jar:1.19]
      at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.jar:1.19]
      at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.3.7.jar:1.3.7]
      at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.jar:1.19]
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.jar:1.19]
  </code></pre>
  
  <p>I am successfully able to run Eureka service with single instance. I am only facing issues for two instances. Following demo example from github: [<a href="https://github.com/rcapraro/spring-cloud-sample][1]" rel="nofollow">https://github.com/rcapraro/spring-cloud-sample][1]</a></p>
  
  <p>What I also noticed in logs is tomcat embeded server is getting started on port-8080 instead of 8761/8762, not sure why?</p>
  
  <p>Please help!</p>