Cefazolin is contraindicated in patients with a known allergy to cephalosporins or a history of severe hypersensitivity to penicillins, due to possible cross-reactivity. Caution is advised in patients with renal impairment, as dosage adjustments may be necessary.