I didn't start getting rib pain until about 4-5 years ago. Not fun...
They don't know what causes it so it could be alot of things. Robin123 is correct, too. It's hard to tell.
The only time I got rid of pain was when I took anti-parasite herbs for 9 months. I haven't been able to keep up with it so my pain came back. Dealing with parasites is not easy.
You can try an herbal protocol. Parastroy is very good but there are many. It's good to start off slowly & ramp it up. It can make you quite ill if you have them. It takes time.
Doing some light stretching or chi gung, tai chi, etc. can help. Swimming helps me, too, but I don't have access to a pool right now. You can try some foam roller exercises as well. It's actually good to do a little exercise with back pain if you can tolerate it. Don't overdo it.