python – ECONNRESET while fetching request from node js to gunicorn api

So I have a simple api service in gunicorn, it just returns json:

    def test():
        return jsonify({"status": "success"})

And i try to make some sort of Load testing and send lots of requests from node js service:

for(let i = 0; i < 100; i++) {
        fetch('https://' + 'localhost' + ':' + PORT + '/test', {agent: httpsAgent})
                .then(res => res.json())
                    .then(json => {
                    .catch(error => {

But if I increase cycle counter to 300, I get an error:

FetchError: request to https://localhost:PORT/test failed, reason: read ECONNRESET

How can I fix it?

Read more here: Source link