you can't use 1031 on a personal residence and the deferral of gain by buying a new house has not been in the tax code for decades.
there is a possiblle home sale exclusiom available of up to $500K.
assuming you are married then one spouse or both must have owned the property for any of 2 out of five years before sale, and again assuming you are married both must have occupied the house as their main reseidence for 2 out of 5 years befor sale. if yo ever rented the property there are anddition rules whic would require any deprecition allowed or tken to not qualify for tthe exclusion. thisexclsuion can only be used once every two year from the date of the prvious sale.
if you don't meet both 2 year rules a reduced exemption each having special rules may be available due to
job chage or
move for health resons or
move due to unforseen circumstance
there is the home sale worksheet that should take you through all the scenarios.
The new purchase doesn't matter.
If you made more than a 250,000 (500,000 for joint) gain then the amount over it is taxed. Doesn't matter what you did with the proceeds like buy another house or pay off the mortgage. The rule about rolling over the gain to the next house went out in May 1997. But if you rolled over a gain before then it will decrease your cost basis when you sell after May 1997.
See publication 523 Selling your home
https://www.irs.gov/pub/irs-pdf/p523.pdf
Enter a primary house sale under
Federal Taxes
Wages and Income
Choose Explore on my own or I'll choose what to work on (if it comes up)
Then scroll down to the last section - Less Common Income
Sale of Home - Click the Start or Update button