To claim the exclusion of gain when you sell your main home, you must meet the ownership and use tests. This means that during the 5-year period ending on the date of the sale, you must have:
1) Owned the home for at least 2 years (the ownership test), and
2) Lived in the home as your main home for at least 2 years (the use test).
Exception. If you owned and lived in the property as your main home for less than 2 years, you can still claim an exclusion if you sold the home due to a change in health or place of employment. The maximum amount you can claim will be reduced.
If the exceptions do not apply, you must pay tax on the capital gain you realize when you sell the house. There is no tax penalty, it is just that you must pay tax on the gain.