ERR_CONNECTION_CLOSED after long operation

Welcome @david-silva987 !

You’re encountering one of (possibly) 4 or 5 different timeout situations.

Effectively, there’s nothing you can do. Unless you’re working with a completely internal and fully controlled network environment, at some point, these connections will time out - and will be disconnected by equipment between you and the browser that is making the request.

Side note: On a different issue regarding the stability and reliability of your system, you should never start processes from within your Django process. For more on this, see my responses at Django thread for opc ua/ modbus connection - #2 by KenWhitesell and I'm new to WebDev, explain to me why or why it wouldn't be OK for all users to access a global Lark() parser object? - #7 by derek-olson, and the messages they link.

As a general pattern, you should be using Celery (or something like it) to run these types of long-running tasks. They don’t belong / are not properly suited for being run within your Django context.