I get achy legs at night too. I think it's RLS or maybe something to do with a disc or pinched nerve in my lower back.
Rubbing my feet helps, so does IcyHot. Weirdly what I find really effective is putting the AC on high and going to bed bare-legged. The cold air really takes the edge off the pain (so do cool sheets/blankets), don't know why.