The sound of hammering in the pipes when the water is off is due to a buildup of pressure that is released when a water-based appliance starts running or water is used in a faucet. The noise happens in particular when the water is shut off suddenly, which forces a wave of pressure through the pipes that will produce banging that varies in loudness according to the pipe material. The harder the material, the louder the noise.
The best way to stop noise in the pipes caused by water hammering is the use of a device called a water hammer arrester or air chamber. The water hammer arrester is manually attached to the plumbing system and adds air to the system, causing the pressure to disperse. The mechanism, which is often bullet-shaped, is attached to the water pipes. Contact a plumber if you are not sure whether you have a water hammer arrester or if you do not have one and are experiencing water hammer in the pipes.
Over time, a water hammer arrester may be arrested, which allows the banging noise to return. Turn off the home water supply and find the lowest water faucet in or outside the home, whether this is in the basement or home exterior. Open the lowest water faucet and return indoors and open some of the water faucets at higher points in the home, such as upstairs. Allow the low water faucet to drain for five minutes and then close all water faucets, starting at the top and working down. Turn the main water supply back on. If the water faucet method works and the hammering stops, the water hammer arrester is waterlogged. Though the problem may be solved temporarily, the issue is likely to return. Contact a plumber to replace the water hammer arrester.
Another way to help resolve the water pressure issue that causes the noise in the pipes is to close water valves slowly to prevent sudden bursts of pressure in the pipes. A one-way surge tank can also be installed in the home to combat the problem. Contact a plumber for assistance.