Request timeout to localhost/127.0.0.1

We are using a test that starts a service that runs on localhost:19001. On CircleCI the test fails
with
java.util.concurrent.TimeoutException: Request timeout to localhost/127.0.0.1:19001 after 2000ms

How do we test with a service on localhost?
Do we need to use specific ports or do we need an environment variable for localhost.