A common cause of side or flank pain could be a kidney stone. These are quite painful and can cause obstruction of the urine flow. Don't guess. See a doctor.
The most common cause of side pain is a strained or pulled muscle. However, if you are having fever or symptoms like abdominal pain, nausea, vomiting, or blood in your urine, the pain may have an internal causative factor.
You find out what is causing pain on your side by the process of elminination. You ask yourself first what symptoms you are having that are not muscular related and go from there to next group, like the digestive tract.