Gastritis can cause upper back pain due to nerve connections getting irritated between the stomach and the spine.