A sudden sharp pain under the right rib cage can be startling, especially when it comes out of nowhere. Sometimes it’s nothing more than a pulled muscle or a bad case of gas. Other times, it’s your body telling you something needs attention right now. The tricky part is that the same general location, the upper right side of your torso, sits on top of several important organs: the liver, the gallbladder, the right kidney, and part of the colon, as well as the base of the right lung.
That overlap is exactly why this symptom is so hard to self-diagnose. This guide walks through the most common causes, the warning signs that mean you shouldn’t wait, and what a doctor typically does to figure out what’s going on.
If you’re reading this while actively in severe pain, especially with fever, vomiting, yellowing skin, or shortness of breath, skip to the “When to Seek Emergency Care” section below or call emergency services now.
Where Is This Pain Actually Coming From?
Doctors refer to this general area as the right upper quadrant, or RUQ. It’s one of four sections used to map the abdomen, and it sits just below the right rib cage. Several organs live in or near this space:
- The liver, most of which sits under the right ribs
- The gallbladder, tucked just beneath the liver
- The right kidney, positioned more toward the back
- Part of the large intestine
- The base of the right lung, which can refer pain downward when inflamed
Because so many structures overlap in this region, the exact cause often comes down to details: what the pain feels like, what triggers it, and what other symptoms come with it.
Common Causes of Sudden Sharp Pain Under the Right Rib Cage
Gallbladder Problems (Gallstones and Cholecystitis)
This is one of the most frequent culprits, particularly after a fatty or heavy meal. Gallstones can block the duct that drains the gallbladder, causing a sudden, intense cramping pain in the RUQ that can radiate to the right shoulder blade or back. This is often called a gallbladder attack or biliary colic. It tends to peak within 30 to 60 minutes and then ease off, though it can recur.
If the gallbladder becomes inflamed or infected (acute cholecystitis), the pain is usually more persistent and comes with fever, nausea, and tenderness when someone presses on the area. A classic clinical sign doctors check for is called Murphy’s sign, where pressing under the right ribs during a deep breath causes a sudden stop in breathing due to pain.
Muscle Strain or Costochondritis
Not every sudden sharp pain in this area comes from an internal organ. The intercostal muscles between the ribs can strain from overexertion, an awkward twist, a hard cough, or even a direct bump to the chest wall. Costochondritis, an inflammation of the cartilage connecting the ribs to the breastbone, produces a similar sharp, localized pain that tends to worsen with movement, deep breathing, or pressing directly on the area, and usually improves with rest.
Diaphragm Irritation
The diaphragm, the muscle that separates the chest cavity from the abdomen, sits right above the liver and gallbladder. A spasm here, sometimes from intense exercise or a hard blow to the area, can cause anything from a sharp stabbing sensation to a squeezing cramp. It often radiates toward the right shoulder and typically settles within 15 minutes to a few hours.
Lung Conditions (Pneumonia and Pleurisy)
Because the base of the right lung sits close to the upper abdomen, lung problems can show up as rib pain. Pneumonia and pleurisy (inflammation of the lining around the lungs) both cause sharp pain that gets noticeably worse with deep breaths or coughing. These usually come with additional symptoms like fever, cough, or general malaise.
Kidney Stones or Kidney Infection
The right kidney sits toward the back of the RUQ, and a stone moving through the ureter can cause sudden, severe pain that starts in the flank or back and wraps around toward the front. This pain often comes in waves and is frequently paired with blood in the urine or a frequent urge to urinate. A kidney infection (pyelonephritis) causes a steadier ache in the same region, along with fever and urinary symptoms, and needs prompt medical treatment.
Liver Inflammation
The liver itself doesn’t have many pain receptors, but when it swells, from a viral infection like hepatitis, heavy alcohol use, fatty liver disease, or certain medications, it can stretch the surrounding tissue and cause a dull, steady ache rather than a sharp one. This is often accompanied by fatigue, nausea, or in more advanced cases, jaundice (yellowing of the skin or eyes) and darker urine.
Digestive Issues
A duodenal ulcer can cause pain in the upper right area, often a few hours after eating, and may ease temporarily with antacids. Indigestion, acid reflux, and even trapped gas can also produce a sharp, if usually short-lived, pain under the right ribs.
When to Seek Emergency Care
Most causes of rib cage pain are uncomfortable but not dangerous. Some are not something to wait out. Based on guidance from emergency medicine and gastroenterology sources, go to the emergency room or call emergency services right away if your pain comes with any of the following:
- Severe pain that doesn’t ease up after several hours, particularly if it’s getting worse rather than better
- Fever, especially above 101°F (38.3°C)
- Yellowing of the skin or eyes (jaundice)
- Persistent vomiting, or vomiting blood, or vomit that looks like coffee grounds
- Blood in your stool, or black, tarry stools
- Shortness of breath, a rapid heartbeat, or chest pain along with the rib pain
- Pain that started near the belly button and has moved to the lower right abdomen (a pattern associated with appendicitis)
- Confusion, dizziness, or fainting
- You are pregnant and have RUQ pain along with a severe headache, vision changes, or swelling these can be signs of preeclampsia and need prompt evaluation
These symptoms can point to conditions like acute cholecystitis, a bile duct obstruction, appendicitis, pancreatitis, a lung condition like pulmonary embolism, or a kidney infection, several of which can become dangerous within hours if untreated. It is far better to be evaluated and find out it’s minor than to wait through something serious.
When It’s Probably Safe to Monitor at Home
If the pain is mild to moderate, doesn’t come with any of the warning signs above, and seems connected to something like recent exercise, a cough, an awkward sleeping position, or a heavy meal, it may be reasonable to rest, avoid straining the area, and use an over-the-counter pain reliever as needed. That said, if pain persists beyond a few days, keeps recurring, or you’re simply unsure, it’s worth having a doctor take a look rather than guessing See our latest blog.
How Doctors Figure Out the Cause
Because so many different conditions can cause pain in this same spot, getting an accurate diagnosis usually involves more than a conversation. A typical workup might include:
- A physical exam, including checking for tenderness and testing for Murphy’s sign
- Blood tests, to check liver function, look for signs of infection or inflammation, and assess pancreatic enzymes
- Urinalysis, if a kidney issue is suspected
- Imaging, most often an ultrasound to look at the gallbladder and liver, sometimes followed by a CT scan if the picture isn’t clear
In many cases, once a serious cause has been ruled out, that alone is reassuring, even if the exact source of milder pain stays a bit uncertain.

