Cannot access REST API port inside Docker

I have an issue in which I get “connection refused” when trying to access the localhost with the specified port from within the container. What needs to be configured?