It can also be present in diabetes, hypothyroid state.
Poor circulation , some medicines also can cause muscle spasm.
You may try some home measures-
Take plenty of fluid, fruits, vegetables .
Regular exercise or a walk daily to keep you active.
Stretching or gentle massage can also be helpful.
Avoid coffee, alcohol, tobacco etc. if you take them.