From IRS
Publication 523 - Selling your home: "If you don't meet the Eligibility Test, you may still qualify for a partial exclusion of gain. You can meet the requirements for a partial exclusion if the main reason for your home sale was a change in workplace location, a health issue, or an unforeseeable event.'
Please view the publication for all the information you need to know for excluding part - or all - of the gain on the sale of your home.