title: Feign client building URL using app name instead of hostname
body: <p>In a nutshell:</p>
  
  <p>feign client tries to call <a href="http://MyApp/endpoint" rel="nofollow noreferrer">http://MyApp/endpoint</a> instead of <a href="http://10.0.1.24:8080/endpoint" rel="nofollow noreferrer">http://10.0.1.24:8080/endpoint</a></p>
  
  <p>I have an application with instances in AWS registering to an Eureka server and a feign client on the same Eureka server trying to communicate with the application (server is also client of itself if you will).</p>
  
  <p>This is an sample of the /eureka/apps output on the server:</p>
  
  <pre><code>&lt;application&gt;
          &lt;name&gt;JSAPI&lt;/name&gt;
          &lt;instance&gt;
              &lt;hostName&gt;10.0.1.24&lt;/hostName&gt;
              &lt;app&gt;JSAPI&lt;/app&gt;
              &lt;ipAddr&gt;10.0.1.24&lt;/ipAddr&gt;
              &lt;status&gt;UP&lt;/status&gt;
              &lt;overriddenstatus&gt;UNKNOWN&lt;/overriddenstatus&gt;
              &lt;port enabled="true"&gt;8080&lt;/port&gt;
              &lt;securePort enabled="false"&gt;443&lt;/securePort&gt;
              &lt;countryId&gt;1&lt;/countryId&gt;
              &lt;dataCenterInfo class="com.netflix.appinfo.AmazonInfo"&gt;
                  &lt;name&gt;Amazon&lt;/name&gt;
                  &lt;metadata&gt;
                      &lt;public-ipv4&gt;52.91.157.255&lt;/public-ipv4&gt;
                      &lt;accountId&gt;831427253318&lt;/accountId&gt;
                      &lt;local-hostname&gt;10.0.1.24&lt;/local-hostname&gt;
                      &lt;public-hostname&gt;ec2-52-91-157-255.compute-1.amazonaws.com&lt;/public-hostname&gt;
                      &lt;instance-id&gt;i-1f86e68c&lt;/instance-id&gt;
                      &lt;local-ipv4&gt;10.0.1.24&lt;/local-ipv4&gt;
                      &lt;instance-type&gt;m4.large&lt;/instance-type&gt;
                      &lt;vpc-id&gt;vpc-3c5e155b&lt;/vpc-id&gt;
                      &lt;ami-id&gt;ami-ee5737f9&lt;/ami-id&gt;
                      &lt;mac&gt;0e:3c:e0:fa:3f:1c&lt;/mac&gt;
                      &lt;availability-zone&gt;us-east-1a&lt;/availability-zone&gt;
                  &lt;/metadata&gt;
              &lt;/dataCenterInfo&gt;
              &lt;leaseInfo&gt;
                  &lt;renewalIntervalInSecs&gt;30&lt;/renewalIntervalInSecs&gt;
                  &lt;durationInSecs&gt;90&lt;/durationInSecs&gt;
                  &lt;registrationTimestamp&gt;1478146401223&lt;/registrationTimestamp&gt;
                  &lt;lastRenewalTimestamp&gt;1478152383740&lt;/lastRenewalTimestamp&gt;
                  &lt;evictionTimestamp&gt;0&lt;/evictionTimestamp&gt;
                  &lt;serviceUpTimestamp&gt;1478146378932&lt;/serviceUpTimestamp&gt;
              &lt;/leaseInfo&gt;
              &lt;metadata class="java.util.Collections$EmptyMap"/&gt;
              &lt;homePageUrl&gt;http://10.0.1.24:8080/&lt;/homePageUrl&gt;
              &lt;statusPageUrl&gt;http://10.0.1.24:8080/info&lt;/statusPageUrl&gt;
              &lt;healthCheckUrl&gt;http://10.0.1.24:8080/health&lt;/healthCheckUrl&gt;
              &lt;vipAddress&gt;JSAPI&lt;/vipAddress&gt;
              &lt;secureVipAddress&gt;JSAPI&lt;/secureVipAddress&gt;
              &lt;isCoordinatingDiscoveryServer&gt;false&lt;/isCoordinatingDiscoveryServer&gt;
              &lt;lastUpdatedTimestamp&gt;1478146401223&lt;/lastUpdatedTimestamp&gt;
              &lt;lastDirtyTimestamp&gt;1478110734306&lt;/lastDirtyTimestamp&gt;
              &lt;actionType&gt;ADDED&lt;/actionType&gt;
          &lt;/instance&gt;...
  </code></pre>
  
  <p>The client code is like so:</p>
  
  <pre><code>@FeignClient("JSAPI")
  public interface JsapiCustomerClient {
  
      @RequestMapping(method = RequestMethod.POST, value = "/customers")
      public void createCustomer(@Valid @RequestBody CustomerConfig customer);
  }
  </code></pre>
  
  <p>I get the following error when trying to execute the method:</p>
  
  <pre><code>Connection refused executing POST http://JSAPI/customers
  </code></pre>
  
  <p>I expected it to try and call POST <a href="http://10.0.1.24:8080/customers" rel="nofollow noreferrer">http://10.0.1.24:8080/customers</a></p>
  
  <p>Any clue? This works on my local, fails once in the cloud.</p>
  
  <p>Thanks</p>
  
  <p>EDIT: Adding pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;com.knetikcloud&lt;/groupId&gt;
          &lt;artifactId&gt;clustermanager&lt;/artifactId&gt;
          &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
      &lt;artifactId&gt;clustermanager-server&lt;/artifactId&gt;
      &lt;name&gt;clustermanager-server&lt;/name&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-eureka-server&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.knetikcloud&lt;/groupId&gt;
              &lt;artifactId&gt;clustermanager-core&lt;/artifactId&gt;
              &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-config-server&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-oauth2&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-feign&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
              &lt;artifactId&gt;aws-java-sdk&lt;/artifactId&gt;
              &lt;version&gt;1.11.45&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.json&lt;/groupId&gt;
              &lt;artifactId&gt;json&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
              &lt;artifactId&gt;aws-java-sdk-acm&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
          &lt;/dependency&gt;    
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
              &lt;!-- Packages the application to run in Elastic Beanstalk --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;descriptor&gt;assembly/beanstalk.xml&lt;/descriptor&gt;
                      &lt;finalName&gt;${project.name}&lt;/finalName&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;single&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;description&gt;A Eureka server paired with JSAPI apps specific status endpoints. The server is used to manage instance and customer status within a JSAPI cluster.&lt;/description&gt;
  &lt;/project&gt;
  </code></pre>