title: Spring WebClient Connection Refused Error
body: <p>When I'm trying to send POST request with WebClient, I get the following error.However if I try to send the request to the same uri using postman it is successful.Please help me out on this I am stuck in this issue and I am new to Spring WebFlux.</p>
  <p>threw exception [Request processing failed; nested exception is reactor.core.Exceptions$ReactiveException: io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:8080] with root cause\n+ Throwable: java.net.ConnectException: finishConnect(..) failed: Connection refused\n at io.netty.channel.unix.Errors.throwConnectException(Errors.java:124)\n at io.netty.channel.unix.Socket.finishConnect(Socket.java:243)\n at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:672)\n at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:649)\n at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:529)\n at</p>
  <p>My WebClient Code to Send Post Req:</p>
  <pre><code>String success =
      webClient
          .post()
          .uri(&quot;/sendRequest&quot;)
          .contentType(MediaType.APPLICATION_JSON)
          .accept(MediaType.APPLICATION_JSON)
          .headers(
              httpHeaders -&gt; {
       
                httpHeaders.add(
                   headerName, headerValue);
  
              })
          .body(Mono.just(messageBody), String.class)
          .exchange()
          .flatMap(
              response -&gt; {
                HttpStatus httpStatus = response.statusCode();
                if (httpStatus.is2xxSuccessful()) {
                  System.out.println(&quot;Message posted&quot;);
                } else {
                  System.err.println(&quot;Message FAILED. Status=&quot; + httpStatus.toString());
                }
                return response.bodyToMono(String.class);
              })
          .block();
  </code></pre>
  <p>}</p>
  <p>//My WebClient Builder Code:</p>
  <pre><code>public WebClient getWebClient() {
    return WebClient.builder().baseUrl(this.MyUrl()).build();
  }
  </code></pre>