The 2-out-of-5-year rule says you can exclude up to 250,000 (500,000 for many married couples) of gain on a primary residence if you’ve owned and lived in it for at least two of the five years before sale. The two years do not have to be consecutive, but you usually can’t use this exclusion more than once every two years.