This paper focuses on hadron mass effects in calculations of semi-inclusive kaon production in leptonDeuteron deeply inelastic scattering at HERMES and COMPASS kinematics. In the collinear factorization framework, the corresponding cross section is shown to factorize, at leading order and leading twist, into products of parton distributions and fragmentation functions evaluated in terms of kaon-and nucleon-mass-dependent scaling variables, and to respect gauge invariance. It is found that hadron mass corrections for integrated kaon multiplicities sizeably reduce the apparent large discrepancy between measurements of K þ þ K − multiplicities performed by the two collaborations, and fully reconcile their K þ =K − ratios.