Water hammer is a hydraulic phenomenon that is caused by a sudden change in the velocity of the water. This happens when there is excessive building water pressure, there is poorly supported water supply piping, when certain fixture valves and controls may be prone to causing water hammer as they shut off high velocity flow very quickly, when water piping that is too small for the flow rate of water through the building piping, or when there is missing water hammer noise suppression device or air riser to absorb the shock of change in water velocity when water is suddenly shut off.
Try draining the building water supply piping: if your building supply piping includes one or more air risers – vertical water pipes that end in a cap or stub – you may be able to stop water hammer noise by draining the building piping to re-admit air into the riser pipe.
This should fix the problem for several years though eventually air in the riser may become absorbed into the water and need to be recharged. If your air risers don’t keep working there may be a plumbing air leak in the building piping system.
Try adding a water hammer arrestor or noise suppression device sold at building or plumbing suppliers. Water hammer arrestors are designed not to lose their air charge. Install the water hammer arrester at or close to the plumbing fixture or faucet that seems most to cause the water hammer noise.
Check the building water pressure: if the building water pressure is too high, water hammer noise may be more likely. If water pressure is 80 psi or higher, you almost certainly need to install a pressure regulator or adjust the existing one.
Check the support for building water supply piping: water pipe noises may also be due to excessive movement (which also risks water pipe leaks), especially if your water supply piping is copper or another metal.