In economics, a shortage or excess demand is a situation in which the demand for a product or service exceeds its supply in a market. It is the opposite of an excess supply (surplus).
In a perfect market (one that matches a simple microeconomic model), an excess of demand will prompt sellers to increase prices until demand at that price matches the available supply, establishing market equilibrium. In economic terminology, a shortage occurs when for some reason (such as government intervention, or decisions by sellers not to raise prices) the price does not rise to reach equilibrium. In this circumstance, buyers want to purchase more at the market price than the quantity of the good or service that is available, and some non-price mechanism (such as "first come, first served" or a lottery) determines which buyers are served.
In common use, the term "shortage" may refer to a situation where most people are unable to find a desired good at an affordable price, especially where supply problems have increased the price. "Market clearing" happens when all buyers and sellers willing to transact at the prevailing price are able to find partners. There are almost always willing buyers at a lower-than-market-clearing price; the narrower technical definition doesn't consider failure to serve this demand as a "shortage", even if it would be described that way in a social or political context (which the simple model of supply and demand does not attempt to encompass).
Shortages (in the technical sense) may be caused by:
Decisions which result in a below-market-clearing price help some people and hurt others. In this case, shortages may be accepted because they theoretically enable a certain portion of the population to purchase a product that they couldn't afford at the market-clearing price. The cost is to those who are willing to pay for a product and either can't, or experience greater difficulty in doing so.