title: spring-boot Autowired DiscoveryClient RestTemplate UnknownHostException
body: <p>I'm using spring boot 1.3.3</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.3.3.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>I'm using Brixton.RC1 for my spring cloud dependencies</p>
  
  <pre><code>&lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt;
              &lt;version&gt;Brixton.RC1&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  </code></pre>
  
  <p>My Application is setup with these annotations:</p>
  
  <pre><code>@EnableDiscoveryClient
  @SpringBootApplication
  public class Application {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>I have a rest controller with service in it:</p>
  
  <pre><code>@RestController
  public class MyController {
  
      @Autowired
      private MyService myService;
  </code></pre>
  
  <p>And in my service I'm trying to use an autowired rest template to call out to another eureka registered service.</p>
  
  <pre><code>@Service
  public class MyServiceImpl {
  
      private final ParameterizedTypeReference&lt;Answer&gt; ANSWER = new ParameterizedTypeReference&lt;Answer&gt;() {};
  
      @Autowired
      private DiscoveryClient discoveryClient; //just here for testing
  
      @Autowired
      private RestTemplate restTemplate; //
  
      public String someCoolMethod(String input){
          log.info("Instance available? " + isInstanceAvailable());
  
          final RequestEntity&lt;String&gt; requestEntity = RequestEntity.post(URI.create("http://myotherservice/othermethod")).accept(MediaType.APPLICATION_JSON).body(input);
          final ResponseEntity&lt;String&gt; response = this.restTemplate.exchange(requestEntity, ANSWER);
          log.info(response);
          return response.getBody();
      }
  
      private Boolean isInstanceAvailable(){
          List&lt;ServiceInstance&gt; instances = discoveryClient.getInstances("myotherservice");
          for(ServiceInstance si : instances){
              log.info(si.getUri().toString());
          }
          return instances.size() &gt; 0;
      }
  
  }
  </code></pre>
  
  <p>I'm completely confused because I have this working in another project.  Here is the output too:</p>
  
  <pre><code>INFO http://192.168.1.10:1234
  INFO Instance available? true
  ERROR I/O error on POST request for "http://myotherservice/othermethod": myotherservice; nested exception is java.net.UnknownHostException: myotherservice
  </code></pre>
  
  <p>So I can see that both services are registered with Eureka.  MyService is able to:</p>
  
  <ul>
  <li>register with Eureka</li>
  <li>query Eureka for 'myotherservice'</li>
  <li>get a valid response with correct host and port</li>
  </ul>
  
  <p>But the autowired RestTemplate is throwing UnknownHostException.</p>