Docker connection to localhost refused

On linux I started a server at localhost:8090. From a docker container through Jupyter notebook I am trying to send a PUT request to the localhost server. GET requests seem to work just fine from the docker container but PUT requests show the following error.

ConnectionError: HTTPConnectionPool(host=’localhost’, port=8090): Max retries exceeded with url: /xxxxx/xxxxx/xxxxx (Caused by NewConnectionError(‘: Failed to establish a new connection: [Errno 111] Connection refused’))

Using curl from local terminal, I am able to send a PUT request without any problem.

The PUT requests seemed to be working in first 1-2 hours (even from the docker container) but then the error started appearing. Is it possible that there are some connections still alive and the server cannot accept any more? Restarting the server and my machine did not fix the problem.

Source: StackOverflow