If you are experiencing rib pain while sleeping, then the possibility is that you need to change your mattress.