For the past few weeks my iPhone would sometimes not ring at all when a person called. It did not even vibrate. But after I would check it, it would work. It was a real mystery. I found out the reason today. The iPhone has a setting called Do Not Disturb. It is easy to turn on by mistake if you press the "moon" symbol. When it is on you will see a picture of a crescent moon near the battery power level on top right. I never noticed it was on. This causes the phone to not ring or vibrate when it is locked. Once I turned it off in my settings, everything was working again!