Steel pipe nipples can sometimes break inside the threaded ports on top of a water heater. This is most likely caused by rust which makes it difficult to remove the broken nipple. If you cannot remove the nipple, place a flat screwdriver against the nipple and gently hit the handle with a hammer to bend the steel ring holding the pipe in place. Usually this will loosen the rust enough to remove the nipple. If you still cannot remove it, try cutting the steel rung with a small hacksaw blade. Be careful not to cut beyond the threads on the steel ring. It should be easier now to pry out the broken nipple
Before installing the new pipe nipple, use a pipe tap to clean the threads on the water heater port. Then wrap the new pipe nipple with Teflon tape before inserting it. Remember that the pipe is usually just ¾ inch.