This is a printer side problem and no host problem.
Typical reasons are overheating of stepper drivers, cross talk to endstops from motors/heaters with end stop check always on, jerk/acceleration too high so you loose some steps and mechanical reasons are also possible even if you exclude them:-)
If it is always away from one endstop it is normally cross talk. If it is random direction it is one of the other reasons.