green, leafy vegetables, pumpkin seeds, edamame, bananas, avocados, beans, and nuts and seeds are all foods rich in magnesium, which helps muscles relax and induces a sleepy state, mehta said. a lack of magnesium can cause restless leg syndrome and muscle spasms. certain foods contain an amino acid called tryptophan.