What causes pain on the right side under the rib cage?

Multiple things. Possibilities include muscle pain, gallbladder problems, liver problems, stomach problems. Sometimes lung problems could also cause that.