Pain in the joints at 4:00am

Jess
I'm 18 years old and if I stay up at night (I have insomnia so that's pretty much every night) I get very bad pains in my joints and worse in my hips. Is there any way I can prevent this, and does anyone know why it is happening?