Under IRS Publication 523, the home sale exclusion applies only to your main home, and only if you meet both tests during the five years ending on the sale date: the ownership test (you owned the home for at least two years) and the use test (you lived in it as your main home for at least two years). You generally cannot use the exclusion again within two years of your last sale using it.
If you sell for a job change, health reasons, or an unforeseen circumstance and don't fully meet the tests, you may qualify for a partial exclusion. Your gain is the sale price minus your adjusted basis (what you paid, plus qualifying improvements, minus any depreciation you took). If a home was rented out, the rules get more detailed, so check the publication.
Your checklist
FAQ
Q: How much gain can I exclude?
A: Up to $250,000, or up to $500,000 if you file a joint return with your spouse and meet the tests.
Q: What if I haven't owned or lived in the home for two full years?
A: You may still qualify for a partial exclusion if the sale is due to a change in place of employment, health reasons, or an unforeseen circumstance.
Q: Does the exclusion apply to a vacation or rental property?
A: No. The exclusion applies to your main home; other property has different rules.