Connection rejection error when files are processed

I am processing my csv batch files. (These are 22 files).
It starts processing but then it give me this error:
This is snippet of my code:

— BATCH PROCESSING —

for i in range(0, len(csv_files), batch_size):
print(f"\n==== Processing batch {i//batch_size + 1} ====")
process_batch(csv_files[i:i + batch_size])

Error:

? Failed to process EMG****9: HTTPConnectionPool(host=‘localhost’, port=35570): Max retries exceeded with url: /execute (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x7f216c8f3b50>: Failed to establish a new connection: [Errno 111] Connection refused’))