There's no clear answer to what causes leg spasms at night. The cramps can occur at any age-group, but tend to occur in middle aged, and older populations. Cramps may be due to overexertion, muscle or nerve injury, prolonged immobilization, electrolyte imbalance, diabetes or even dehydration. Interestingly, pregnant women have a higher likelihood of experiencing these symptoms.
Although it is no longer recommended, when I was studying the lower extremity, tonic water was recommended for these cramps, as they contained quinine. This is no longer recommended in the united States.
Due to the many possibilities listed, I suggest that you consult your personal physician for a thorough workup.
I get those too, all the time. I thought it was because I injured my hip and knee, which may very well be my case. I can normally get it to stop by stretching and moving around a bit.