Good afternoon Bill. It is not clear from your question if the sales price is over $500,000 or if the gain is over $500,000. The $500,000 exclusion that would be available to you and your wife on a joint return is an exclusion of GAIN. The gain would be determined by taking the sales price and subtracting your basis (which among other things includes your purchase price and cost of improvements). Here is a link to a useful TurboTax article that gives great information on the selling a home and claiming the exclusion.
As to your question about a possible 1031 exchange; this generally applies to investment property. Although your home is one of your biggest investments; it is not considered investment property under IRS rules.
**Say "Thanks" by clicking the thumb icon in a post
**Mark the post that answers your question by clicking on "Mark as Best Answer"