A lot of people think they gain muscle during weight training. The real growth happens during recovery while you're sleeping. When you're lifting weights, you're actually tearing and breaking down your muscles. During rest your muscles are repairing. If you don't get enough sleep your body won't have enough time to completely recover.
In Stage 3 sleep, also known as deep sleep, more blood rushes to your muscles. By increasing blood flow to the muscles, it sends more oxygen & nutrients to them so that they can repair and grow.
During sleep your body also produces hormones that aids in building muscle called HGH (Human Growth Hormone). Getting enough sleep will ensure your body is releasing enough HGH to help you build muscle and gain weight. HGH has also been seen as the hormone that keeps us young. Low HGH may lead to higher risk of heart disease and diabetes.
Most people need 7-9 hours of sleep to feel fully rested. But everyone is different. Try going to bed at the same time every evening, and see how you feel. Some of you may need more sleep than others. Make sure you're not neglecting sleep during your weight gain journey. That way you're maximizing blood flow and HGH, to help you recover & build muscle.