I've got this problem in my house.

I live in a 41 year old townhouse, and whenever after I turn off hot water all of a sudden a pipe somewhere inside the walls starts to bang.
It's not too long, but it's definitely annoying. I can't tell where exactly it is coming from, which pipe that is.

I cannot hear the sound from my basement, only from certain parts of the house. It continues for about 2-5 minutes after I turn off hot water; after shower, or flushing toilet or just after using a faucet. It seems that the noise starts when the water is going down the pipe.

This problem only occurs in the winter or when it's cold outside, never in the summer.

I've tried draining the pipes in the house, turning off the main hot+cold water supply and opening all the faucets that is; did not help.

I have no idea how to resolve/fix this issue.

I would really appreciate some help identifying the problem or giving some suggestions on how to fix it !

Thank you very much !