Pyelonephritis also can happen if bacteria from an infection elsewhere in your body spread through your bloodstream to your kidneys.