I am assuming your piping is galvanized iron. Your piping is more than likely clogged with rust deposits that were loosened from turning the water on and off. Recomend getting purging the piping out with presurized C02 from the end point of use. Also this is not a sure fix and could clog up your piping even more. But you should also check the water heater shut-off valve, perhaps the valve has malfunctioned.