Capital gains on sale of home

This year we sold our primary residence and realized a net gain in excess of $500,000. We file as married filing jointly. Will we owe capital gains tax? Is there any way to avoid it?