Rib pain

I am 28 years old...I feel pain under right rib only when I sleep on my Right side. When I sleep on the left side or the back, pain is not strong. I feel pain only when I sleep on the right side. Please help me out.

See your doctor and ask about costochondritis and gastritis.  Do you have the pain after eating snd do certain foods trigger it?  Do you get any  acid reflux?