You just finished running PEX throughout your basement, and now you’re staring at the two copper stubs sticking out of your electric water heater. The thought crosses your mind: Can I just clamp a PEX straight onto those nipples and call it done? It would save a trip to the hardware store and maybe an hour of work. Don’t do it.
Connecting PEX directly to an electric water heater is not allowed under most plumbing codes, and for good reasons involving heat, expansion, and long-term reliability. This article walks through the specific requirements, the engineering behind them, and the exact way to transition from the water heater to PEX without violating code or risking a leak. You’ll get the numbers, the code sections, and the practical steps so you can make the connection once and forget about it.
Before diving in, if you’re looking for a solid reference to keep your whole plumbing project straight, grab a copy of We See, We Do, So Can You! (Better Connect Books). It covers the step-by-step thinking behind jobs like this, including transition fittings and code notes. Worth having on the bench while you work.
The 18-Inch Metal Stub Rule
The most common code requirement across the US and Canada is that you cannot attach PEX directly to the water heater. You need at least 18 inches of metal pipe — typically copper or stainless steel — between the heater outlet and the first PEX fitting. This rule comes from the International Plumbing Code (IPC) and the Uniform Plumbing Code (UPC), both of which specify a minimum 18-inch metallic pipe segment.
Why 18 inches? Two reasons. First, the metal pipe acts as a heat sink. The water right at the heater outlet can spike well above the set thermostat temperature if the safety cutoff fails or if sediment builds up. PEX is rated for continuous service at 180°F for standard PEX (PEX-B) and 200°F for PEX-A. Thermal spikes above that weaken the pipe wall over time. A metal stub dissipates that heat before it hits the PEX, keeping the plastic within its safe zone.
Second, fire resistance. If a fire starts near the water heater, a metal stub won’t melt or burn like PEX would. That length of copper gives firefighters a few more minutes of water supply before the line fails. It’s a small detail that saves lives when it matters.
Some local codes allow a 6-inch metal nipple if you use a special heat-trap nipple or a dielectric union rated for direct connection. But those are exceptions, not the rule. Stick with 18 inches unless your inspector says otherwise.
Why Direct Connection Causes Problems
Even if code somehow didn’t require the metal stub, connecting PEX directly is a bad idea from a materials standpoint. Here’s what actually goes wrong.
Heat Degradation
Standard PEX (ASTM F876) has a maximum continuous operating temperature of 180°F at 100 psi. Electric water heaters are set to 120–140°F normally. That’s fine. But thermostats drift. Heating elements can stick on. The temperature and pressure relief valve (T&P valve) might fail. If that happens, water inside the heater can hit 190°F or higher. PEX exposed to those temperatures for even a few hours starts to soften and deform. Over months, the plastic embrittles and cracks at the fitting.
Expansion and Stress
Water heaters expand and contract as tanks heat and cool. Copper or steel nipples handle that movement rigidly. PEX, being flexible, can twist and sag if not supported. When you clamp PEX directly onto the heater nipple, every thermal cycle puts strain on the fitting. That strain loosens grip rings or crimp rings over time, especially on the hot side. I’ve seen leaked connections that looked fine from the outside but the ring had slid back 1/16 inch.
Dielectric Corrosion
If you go directly from a copper or brass heater nipple (most are brass or copper) into a PEX fitting, the metal-to-metal contact isn’t an issue because PEX doesn’t corrode. But if the heater nipple is steel or if you use a galvanized nipple, you need a dielectric union between the steel and the copper in the house. The metal stub rule usually handles this naturally because you’ll install a copper stub, then a dielectric union before PEX. Skipping the stub means you skip the union too, risking galvanic corrosion at the heater tank threads.
How to Do It Right (Step by Step)
Here’s the no-surprises method for connecting PEX to an electric water heater that passes inspection and lasts decades.
- Install an 18-inch copper or brass nipple into the heater outlet. Use a threaded nipple (male NPT) sized to match the heater’s outlet — usually 3/4-inch for residential electric heaters. Wrap the threads with Teflon tape or pipe dope.
- Add a dielectric union if the nipple is copper and the house piping is copper or steel. Most dielectric unions have a plastic washer inside that stops the metal-to-metal contact. If your house piping is already PEX and the nipple is brass or copper, you can skip the union and go straight to a transition adapter.
- Install a brass or stainless steel transition adapter from the metal stub to PEX. A 3/4-inch female NPT to PEX adapter works. Use Teflon tape on the threads. For crimp PEX, use a brass or stainless PEX adapter. For expansion PEX (PEX-A), use the compatible expansion adapter (typically clear or colored).
- Run your PEX line from the adapter. Support the pipe every 32 inches or less. Leave a slight coil or loop to absorb expansion stress from water temperature changes.
- Do both hot and cold sides the same way. The cold inlet also benefits from a metal stub — it prevents heat migration into the cold line and protects the PEX if the heater back-siphons hot water.
One more thing: use stainless steel clamps or crimp rings, not copper rings, on the PEX side if you have a softener or acidic water. Copper rings corrode faster in aggressive water. Stainless holds up better.
| Feature | Direct PEX to Heater (Not Recommended) | 18-Inch Metal Stub + PEX (Code-Compliant) |
|---|---|---|
| Safety (fire & heat) | Poor — plastic melts in fire, heat spike weakens pipe | Excellent — metal stub withstands fire and dissipates heat |
| Code compliance | Fails IPC/UPC in most regions | Meets IPC, UPC, and most local codes |
| Ease of installation | Easy — one coupling | Moderate — need nipple, union, adapter |
| Cost | Low — just a PEX fitting | Moderate — $15–25 for nipple + union + adapter |
| Long-term reliability | Risk of leaks due to heat creep and ring slip | Proven — decades of service with no failures |
Common Mistakes and Material Pitfalls
I see the same errors over and over in DIY installs. Here’s what to avoid.
Using a SharkBite Directly on the Heater Nipple
SharkBite fittings are rated for PEX and copper, but the manufacturer explicitly warns against installing them directly on water heater nipples unless there’s at least 18 inches of copper pipe first. The heat and vibration slowly degrade the O-ring inside the SharkBite. It’ll leak eventually. Stick with the 18-inch stub and a threaded adapter.
Assuming PEX-AL-PEX Is Different
Multilayer PEX (PEX-AL-PEX) has an aluminum layer that gives it a slightly higher temperature rating (200°F continuous) and less expansion. Some manufacturers claim direct connection is okay with their fittings. Local code may not care. Most inspectors still require the 18-inch metal stub because the fire-resistance rule applies to the pipe material, not just its temperature rating. Check with your local building department before skipping the stub.
Mixing PEX Types at the Heater
PEX-A and PEX-B use different fitting systems (expansion vs. crimp). If you use an expansion adapter for PEX-A, don’t switch to a crimp ring on the same line later. The diameters differ slightly, and a crimp ring on PEX-A can crush the pipe. Keep the same system from the heater to the next fixture.
Forgetting the Sediment Trap
Some homeowners connect a flexible copper or stainless steel braided hose straight from the heater to the PEX line. Those hoses are fine for moving the heater a few inches, but they’re not a substitute for the metal stub. They’re also not rated for permanent, unsupported connections. Use them only as a temporary service or for seismic loops, and always with the 18-inch stub in between.
Frequently Asked Questions
Can I use a flexible copper connector instead of a rigid copper stub?
Yes, but only if the flexible connector is listed for water heater use and meets the 18-inch length. Flexible copper supply lines (like those for toilets or faucets) are not rated for the continuous heat and pressure at a water heater outlet. Use a proper 18-inch flexible copper connector with brass nuts, not a braided stainless steel line. The braided ones have a plastic core that can melt.
Do I need a dielectric union if I’m going from brass directly to PEX?
No. PEX is non-metallic, so there’s no galvanic corrosion between brass and plastic. The dielectric union is only needed when connecting dissimilar metals (e.g., copper to steel). If your stub is brass or copper and you transition to PEX with a brass adapter, you’re fine without a union. Some codes still require one for the tank-to-nipple connection if the nipple material differs from the tank’s outlet — check your heater’s tank material (usually steel). A brass nipple into a steel tank needs a dielectric union.
What about PEX-AL-PEX? Is it safe to connect directly?
PEX-AL-PEX has higher thermal limits (200°F continuous) and less expansion. A few manufacturers allow direct connection if you use their specific fittings. However, most local codes override manufacturer claims. The 18-inch metal stub rule is about fire safety, not just temperature rating. I recommend using the stub regardless. If you want to skip it, get written approval from your inspector first.
Does the 18-inch rule apply to both hot and cold water lines?
Yes. The hot water line obviously sees the most heat, but the cold line can also get hot if the heater back-siphons (which happens when the cold supply is shut off and hot water flows backward). Plus, the cold inlet is often connected to the same metal pipe run. To keep things consistent and pass inspection easily, do both sides with an 18-inch metal stub.
Can I connect PEX directly to a tankless electric water heater?
Tankless electric water heaters don’t store hot water, so the risk of sustained high temperatures is lower. That said, the outlet water can still hit 140°F or higher. Most tankless electric units have 3/4-inch copper or brass connections built in. You can run PEX directly to those connections if the manufacturer specifies it’s acceptable. Check the manual. If it says nothing, stick with a minimum 6-inch metal stub. Many installers use 12 inches just because it’s easier to service.
What to Take Away and Do Next
- Never connect PEX directly to any water heater — electric or gas — without at least 18 inches of metal pipe (copper, brass, or stainless steel) in between.
- Use a dielectric union wherever dissimilar metals touch, especially between a steel tank and a copper nipple, or between copper and galvanized pipe.
- Install a brass transition adapter (NPT to PEX) at the end of the metal stub, using Teflon tape on all threaded joints.
- Choose PEX type that matches your fitting system — PEX-A for expansion rings, PEX-B for crimp rings — and don’t mix them on the same line.
- Support all PEX lines within 32 inches of the heater and leave a small expansion loop to absorb thermal growth.
- Check your local building code before starting — a few municipalities allow shorter stub lengths or direct connection with specific fittings. It’s your job to know.
- If you’re unsure about a step, grab a reference like We See, We Do, So Can You! to walk through the full installation sequence.


