Querying docker server in parallel raises connection error – python

In Python3, I am using get.requests() in a parallel loop to query a server that I have running in a docker container (specifically an OSRM server).

I get this error after it successfully queries a few:
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

I think the Docker container has a limit on the number of queries at a time or from a single IP, but I don’t know how to fix it. I’m assuming it’s in the Docker settings.

I initiate the docker container using: docker run --name osrm-nc -t -i -p 6002:5000 -v /homedirs/tml62/osm:/data osrm/osrm-backend osrm-routed --algorithm mld /data/north-carolina-latest.osrm, so noteably, I’m assigning the ports

I’ve set the retries so it can repeat and that sometimes fixes it, but it causes delays and sometimes will still break.

Source: StackOverflow