Rattling pipes are referred to as “water hammer”.
Water hammer occurs when the motion of water comes to an abrupt stop or suddenly the water changes direction of flow in your pipes.
The rattling noise can be stopped by insulating the pipe. Wrapping the pipe with a towel or blanket can be an effective way to control the rattling.
Water hammer can also be treated by recharging the water supply.
By recharging the water supply, the amount of air in the pipes is increased, which, in turn, causes the water to flow freely.
To recharge the water supply, turn off the main water supply valve, and then open all the faucets. When you turn on the main valve, begin shutting the faucets off, one at a time, beginning with the faucet that is lowest in the home.
If this doesn’t solve the problem, you need to contact a plumber.