I/O error on GET in TestRestTemplate getForEntity method

Viewed 12
var restTemplate = new TestRestTemplate();
var actual = restTemplate.getForEntity(new URI("http://localhost:8080/foo"), PatientViewDto.class);

When I try to use this method an Exception occurs

org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8080/foo": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect

1 Answers

This exception (Connection refused) means that there is no service listening on the localhost port 8080.

review this:

  • Check IP and port.
  • Server is up and running.
Related