On a property with its own well, a bang in the pipes usually starts at the pressure tank.
The tank
It stores water under an air charge so the pump does not run for every tap. When the bladder fails, the tank waterlogs: pressure swings, the pump cycles, and valves knock.
Test: pump off, tap open, air valve. Water at the valve means replacement.
Water hammer
A fast-closing valve stops a column of water and the shock runs back through the pipe. Loose or unclipped runs turn that into a knock, often near the heater.
Fixes: arrestors at the offending fixture, securing the run, replacing worn washers.
Pressure
Set it to what the house needs. At this elevation the setting is entirely local, so nobody upstream will correct it for you.
Telling the two noises apart
- Banging follows a tap closing.
- Popping follows the burner or element.
Through a floor they sound similar. They are not the same problem.
Long runs
Rural parcels have pipe between buildings. A shock has more opportunity to find a weak joint, and a leak in an outbuilding may go unnoticed until the ground is wet.
What to have ready
Trigger, timing, pressure, pump behaviour.