Generally 40 feet for ordinary atmospheric-vented household water heater...
Straight run to roof.
Atmospheric means no power vent... just hot air drafting upwards
Google search: gas vent height code
Atmospheric venting code depends on 4 basic factors:
Diameter of vent--- bigger vent, more draft
How many water heaters are connected to same vent
BTU per hour rating of water heater-- the more gas that is burned per hour, the bigger the vent needs to be
How straight the pipe is -- are there any horizontal or lateral runs
Other factors can include
-wind conditions... higher wind across top of vent pipe on roof can reduce draft, and cause downdraft that blows deadly CO into same room as water heater
-vent termination near high walls, trees, high roof peak etc will reduce draft or cause downdraft
-amount of incoming air supply... if water heater is inside a closed room, then there is no air to draft up the pipe, burner will shut down or burn lazy yellow instead of clear blue
-stuff piled up around water heater that obstructs air intake
-dirty air intake screen that reduces air intake
-vent fans inside same room as water heater that pull air down the vent and cause reduction in water heater draft
-generally elbows reduce draft by 10%
-vent cannot terminate near any window door or air intake for another gas appliance
-bird build nest on top of vent pipe after vent termination falls off
-highly acidic gas by-product causes large amount of condensation inside pipe that burns hole in pipe or drips down and damages combustion parts...blower and inline condensate trap and drain might be required
-multiple water heaters installed on same vent line.
Water Heater Timers Save Money
If you need further help, I’m available over the phone at https://www.6ya.com/expert/gene_9f0ef4df2f9897e7