title: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1] failed: Connection refused: connect
body: <p>I'm new to spring-boot and I'm testing spring-boot application using http API, but I got connection error.</p>
  
  <blockquote>
    <p>GET <a href="http://localhost:8080/api/helloworld" rel="nofollow noreferrer">http://localhost:8080/api/helloworld</a></p>
    
    <p>org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1] failed: Connection refused: connect</p>
  </blockquote>
  
  <pre><code>//HelloWorldController.java
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.bind.annotation.RestController;
  
  
  @RestController
  public class HelloWorldController {
      @GetMapping(value="/api/helloworld")
      public String helloWorld(){
          return "helloworld";
      }
  }
  </code></pre>
  
  <p></p>
  
  <pre><code>//helloworld.http    
  GET http://localhost:8080/api/helloworld
  </code></pre>
  
  <p>
  </p>
  
  <p>And It works well with running main java file.</p>
  
  <p><a href="https://i.stack.imgur.com/Vb6Zj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vb6Zj.png" alt="enter image description here"></a></p>
  
  <p>Please let me know where I'm doing wrong. Thank you.</p>