Several things can cause leg cramps at night including restricted blood flow or pinched nerves or muscles when laying down in bed.
The most common cause of leg cramps at night though are Sitting for long periods of time, Over-exertion of the muscles, Standing or working on concrete floors and Sitting improperly.
To prevent leg cramps from occurring at night you should make sure to get plenty of exercise in the day and stretch your legs and leg muscles often and before going to bed.
Leg cramps usually go away on their own within 10 to 15 minutes and are usually nothing to worry about.