Error in unserialize(socklist[[n]]) : error reading from connection while running KNN

This is hard to troubleshoot properly without a reprex. See the FAQ: How to do a minimal reproducible example reprex for beginners.

Generically, the connection error means that an attempt was made to read or write to an file system resource or a remote file that was unsuccessful for some reason such as wrong name, wrong path, wrong file type, or no path to a remove object or inadequate permissions.