You just bought a new electric water heater. The old copper pipes are corroded, and you’d rather run flexible PEX than sweat joints in a tight closet. But then a friend says: “You can’t use PEX for a water heater — the heat will melt it.” Another guy at the supply house swears PEX is fine “as long as you use the brass fittings.” Who’s right?
I’ve been doing residential plumbing for 12 years. I’ve seen PEX done right next to water heaters and I’ve seen it fail. The answer isn’t a simple yes or no — it depends on the code edition you’re under, the distance from the heater, and the specific PEX type you choose. By the end of this article you’ll know exactly what the National Plumbing Code (NPC) says, where people get tripped up, and how to make a connection that passes inspection and actually lasts.
One caveat: the NPC is a model code. Individual states and provinces adopt it with amendments. Always check your local authority. But the rules I’ll cover here apply to the vast majority of jurisdictions that follow the 2026 or 2026 NPC editions.
If you’re tackling this job yourself, a solid reference helps. I’ve used Black & Decker The Complete Guide to Plumbing, Updated 5th Edition for years. It walks through PEX installation, water heater rough-in, and code compliance step by step. Worth keeping on the shelf.

The Straight Rules: What the NPC Actually Says About PEX and Water Heaters
Contrary to rumor, the NPC does not ban PEX for electric water heater connections. But it places restrictions on how close PEX can get to the heater and what materials can touch the hot outlet.
The key code section is NPC Table 7.2.3.2 (or your local equivalent). It lists maximum operating temperatures for PEX: standard PEX (often called PEX-B) is rated for 180°F at 100 psi. Electric water heaters typically top out around 150°F at the tank outlet surface — just under the limit. But the pipe surface temperature can spike higher if it’s within 18 inches of the metal nipples where heat conducts through brass or copper.
Here’s the actual rule that catches most DIYers: Any PEX within 18 inches of the water heater connection must be manufactured with a listed heat-trace rating or be protected by a metal transition fitting. In plain English — you cannot run PEX directly onto the water heater’s inlet/outlet threads. You need at least 18 inches of metal pipe (copper, brass, or stainless steel flex) between the tank and the first PEX fitting. That metal pipe acts as a heat sink so the PEX doesn’t see full tank temperature.
Some inspectors also require the first 18 inches to be visible (not buried in a wall) for inspection. Check your local amendment.
Myth #1: “PEX Will Melt If You Use It Near Any Water Heater”
This is the most common mistake I hear. People think water heater + PEX = disaster. That’s only true if you skip the metal transition or use the wrong PEX type.
Standard PEX (PEX-B, the red/blue stuff from the big box) has a continuous working temperature of 180°F. Electric water heater outlet water runs 120–140°F typically. Even if the heater’s thermostat fails, the high-limit cutoff usually kicks in around 170°F. So the PEX itself won’t melt during normal operation.
The real risk is creep — long-term exposure to water near 180°F can soften PEX and cause fittings to blow off. That’s why the code requires that 18-inch metal heat sink. With that metal section, the PEX never sees more than maybe 140°F on the outside. I’ve pulled apart 10-year-old installations with brass nipples and PEX — pipe looked fine. No discoloration, no swelling.
Where I’ve seen failures: someone used PEX directly on a gas water heater’s outlet (gas units run hotter), or they used polybutylene (old gray stuff) mistaking it for PEX. If you stick with new PEX and follow the 18-inch rule, you’re safe.
Myth #2: “You Have to Use Yellow PEX (PEX-Al-PEX) for Water Heaters”
Not true. Yellow PEX (PEX-AL-PEX) has an aluminum layer that reduces oxygen diffusion — useful for radiant heating systems. For a domestic hot water supply, standard PEX works fine as long as it’s rated for 180°F. PEX-A, PEX-B, and PEX-C all carry that rating. The difference is flexibility and fitting method.
I prefer PEX-B for water heater connections because it’s more resistant to chlorine (common in city water) and has slightly better burst pressure. But any listed PEX type will pass code if installed with the metal transition.
Some people think the aluminum layer makes yellow PEX safer for heat. Actually, the aluminum conducts heat into the plastic faster, so you still need the metal transition. No shortcut. Save the yellow PEX for your in-floor heating loops.
Which Fittings and Materials Work Best? A Real-World Comparison
| Connection Method | Metal Transition Needed? | Heat Tolerance Up to Tank | Ease of Installation | Typical Cost |
|---|---|---|---|---|
| Copper pipe (rigid) → PEX | Yes (18″ copper minimum) | Excellent | Moderate (need to solder) | Mid |
| Brass nipple (NPT) → PEX | Yes (18″ brass nipple) | Good | Easy (thread + crimp) | Low |
| Stainless steel braided flex | Yes (18″ flex counts) | Good | Easiest (no tools) | Low–Mid |
| Direct PEX onto heater (no transition) | No – NOT allowed | Poor – violates code | Easy (but fails inspection) | Lowest |
| Dielectric union + PEX adapter | Yes (dielectric acts as transition) | Good | Moderate (two fittings) | Mid |
I go with a 6-inch brass nipple and a 12-inch copper stub-out to get the full 18 inches. That gives me a threaded connection on the heater side and a crimp PEX connection on the house side. Never had an issue.
3 Practical Gotchas That Trip Up Even Experienced Plumbers
1. The 18-inch rule applies to both hot and cold lines. The cold inlet can see backflow heat from the tank. Same metal transition required. Don’t run PEX straight onto the cold inlet either.
2. Expansion loops. PEX expands when hot. If you run a straight PEX line from the heater to a wall that’s only 12 inches away, the pipe can buckle over time. Give it a gentle loop or use a flex connector. The Black & Decker guide I mentioned shows how to lay it out.
3. Support and straps. Plastic straps melt if they touch the metal pipe near the heater. Use metal straps within the first 2 feet. After that, plastic is fine.
Frequently Asked Questions
Can I use PEX directly on an electric water heater if I use a heat trap nipple?
Heat trap nipples (those with a plastic internal check valve) do not count as a metal transition. The nipple body is brass or steel, so that metal portion counts toward your 18 inches. But you still need 18 total inches of metal pipe. A 4-inch heat trap nipple alone is not enough. Add a copper stub to reach 18.
What about PEX rated for 200°F — does that bypass the 18-inch rule?
No. Even if you find a specialty PEX (e.g., PEX with an oxygen barrier rated to 200°F), the code still requires a metal transition. The rule is about reducing heat transfer to the plastic, not about the plastic’s burst rating. Don’t try to cheat it. Inspectors look for the metal pipe.
Does the NPC require a specific PEX fitting type (crimp, clamp, expansion)?
No. The NPC doesn’t care which PEX system you use. Crimp (ASTM F1807), clamp (ASTM F2098), and expansion (ASTM F1960) are all listed. I prefer expansion rings for water heater hookups because they form a smooth interior — less restriction. But crimp works just as well.
Is stainless steel braided flex hose allowed as the metal transition?
Yes, if the flex hose is rated for potable water and 180°F minimum. Most ½-inch stainless steel braided flex hoses sold for water heaters are rated to 200°F. The braided metal counts as metal pipe. Just make sure the hose is at least 18 inches long. Shorter hoses are common — don’t use a 12-inch hose and then PEX.
What happens if you fail an inspection for using PEX without the metal transition?
You’ll get a red tag requiring correction before turning on the water. You’ll have to cut out the PEX, add the metal transition, and reinspect. It’s a 30-minute fix if you prepared, but a pain if the drywall is already up. Always rough-in the metal piece first, then call for inspection before finishing the wall.
What to Actually Do (So You Never Regret It)
- Measure 18 inches from the water heater’s connection point. Mark it on your pipe.
- Install a metal pipe (copper, brass nipple, or stainless flex) between the heater and that 18-inch mark.
- Use brass or copper fittings for the transition to PEX — avoid galvanized steel on the hot side (corrosion risk).
- Leave a service loop or flexible PEX run to absorb thermal expansion.
- Strap the metal portion with metal straps; after 2 feet you can switch to plastic.
- If your local code says 18 inches from the top of the heater, not from the nipple, follow that. Some areas measure from the tank shell.
- Buy a current code reference like the Black & Decker guide — it’ll save you from trusting internet rumors.

