Avoid capital gains tax when selling and buying a new home
Contributed by Tom McLean
Updated Sep 6, 2026
•11-minute read

If you’re selling your home and planning to buy another, you typically don’t need to reinvest the proceeds to avoid capital gains tax. Instead, you may qualify to exclude up to $250,000 or $500,000 of gain, depending on your tax filing status and whether you meet the ownership and use tests.
Learn how to calculate your gain, increase your basis with eligible improvements and selling costs, and when a 1031 exchange may defer taxes on investment property.1
Key takeaways:
- When you sell a home, you will owe capital gains taxes on the profit you earned.
- There are many ways to reduce the taxes you owe, including by using a 121 exchange, which involves buying another home.
- Even without buying another property, you may have options to reduce the amount of tax owed.
Can you avoid capital gains tax by buying another house?
Yes, it is possible to avoid or reduce the amount of capital gains tax that you owe from selling a home by buying another one.
However, that isn’t the full story.
What matters is whether you’re eligible for something called a Section 121 exclusion, which lets you reduce taxes when selling a primary residence for a profit and reinvesting the money.
Buying another primary residence vs. reinvesting proceeds
A Section 121 exclusion allows the owner of a home who sells it to exclude a portion of the profit they earn.
What sets Section 121 apart from the similar 1031 exchange is that IRS Section 121 applies only to a home you’ve used as a primary residence for at least 2 out of the last 5 years.
It also does not defer taxes but excludes the income from taxation entirely, with no requirement that you use the proceeds to buy a new home. You are free to use it for other purposes or to reinvest it in real estate, securities, or anything else.
See what you qualify for
What are capital gains taxes?
A capital gain is the profit you make when you sell an asset, like a house, for more than you originally paid for it.
For example, if you buy a home for $500,000 and sell it for $600,000, you’ve earned a profit of $100,000.
That profit is your capital gain and is subject to capital gains tax.
Short-term vs. long-term capital gains
A major factor in determining how much tax you owe is whether the gain was a short-term or long-term gain.
If you own an asset for 1 year or less before selling it, the profit is considered a short-term gain. If you hold something for longer than 1 year before selling, profits are long-term gains.
Short-term gains are taxed at your regular income tax rate, while long-term capital gains are taxed at a lower rate ranging from 0% to 20%, depending on your income.
Take the first step toward the right mortgage
Apply online for expert recommendations with real interest rates and payments
How to calculate capital gains tax when selling a house
To estimate how much you owe in capital gains taxes when selling a home, follow these steps.
Sale price, adjusted basis, and taxable gain
The first figures used to determine how much you owe in capital gains taxes are the home’s sale price and its adjusted cost basis.
The sale price is the amount you sell the house for. Adjusted cost basis is the amount you paid for the home, adjusted by factors such as the cost of capital improvements, and any casualty losses or other decreases to the home’s fair market value.
For example, if you buy a home for $250,000 and make a $25,000 capital improvement, your adjusted basis would be $275,000. If you later sell it for $300,000, your taxable gain from the sale would be:
$300,000 – ($250,000 + $25,000) = $25,000.
Net proceeds vs. taxable gain
Once you know the taxable gain from a home sale, you can determine how much you owe in taxes. That will let you arrive at your net proceeds, which is the actual amount you pocket from a home sale.
Using the above example, if you pay 10% in long-term capital gains taxes on your $25,000 taxable gain, you’d pay $2,500 of the $25,000 in taxes, leaving your net proceeds at:
$25,000 - $2,500 - $22,500
What can be deducted from capital gains when selling a house?
You can deduct a few different things from your capital gains to reduce how much tax you owe and improve your net proceeds.
For example, you may be able to deduct costs related to selling the property, such as real estate agent fees. You can also use the Section 121 exclusion to reduce your taxable gains.
Apply for a Home Equity Loan online
The Rocket Mortgage online application is simple and secure
How the Section 121 home sale exclusion works
If you’re selling your primary residence, the Section 121 exclusion allows you to exclude a portion of your profits from capital gains taxes.
How this exclusion works depends on whether you’re married or single. You also must meet a few eligibility requirements.
The $250,000/$500,000 exclusion
When you use the Section 121 exclusion, you can exclude $250,000 if you file taxes as a single person. If you’re married and filing separate returns, both partners can claim the deduction if they meet the other requirements.
You can exclude $500,000 if you’re married and filing a joint return.
The 2-out-of-5-year ownership and use test
A key eligibility requirement for the Section 121 exclusion is that the home you sell must have been your primary residence for at least 2 out of the previous 5 years. You can’t use the exclusion for investment properties.
For a home to be your primary residence, you must live in it for the majority of the year.
Other factors, such as distance to your place of employment, where your immediate family lives, where you file state taxes, where you’re registered to vote, and other factors also can be used to establish your primary residence.
Some exceptions to this requirement apply in special circumstances, such as for members of the military, people who are moving for a job, or people getting divorced.
How often can you use the exclusion?
In general, you can only use the exclusion once every 2 years.
If you own two properties and qualify for the exclusion on both, you need to wait 2 years after selling the first property before you can claim it on the other.
What types of homes may qualify
A wide variety of home types can qualify for this exclusion. Some examples listed by the IRS include:
What if your profit exceeds the exclusion?
If your profit on a home sale exceeds the exclusion, you may still be able to reduce the amount of capital gains you owe by deducting the cost of home improvements or the cost of buying and selling the property.
How improvements can increase your cost basis
If you make capital improvements to your home, you can add the cost of those improvements to your cost basis, reducing your taxable gain from selling the home.
It’s important to note that capital improvements have a precise definition. You can’t write off the cost of any change to the home, such as repainting a few rooms or performing standard maintenance.
Capital improvements make a “substantial and permanent alteration or repair” to your home, generally increasing its value. Things that modernize, extend the life of, or adapt your home to new uses all qualify.
For example, if you add a bedroom to a home or update it to be easier to use for those with mobility impairments, those changes could qualify as capital improvements.
Selling costs and original buying costs
Another adjustment you can make to your capital gains is based on the amount you paid to buy or sell the home. For example, you may be able to adjust your taxable gain by the amount paid for real estate agent fees or staging of the property.
Exceptions and situations that can affect the exclusion
Not every home sale is eligible for a Section 121 exclusion. These are some scenarios where you may not be eligible, or there are exceptions that could affect eligibility.
If you lived in the home for less than 2 years
One of the key requirements to qualify for a Section 121 exchange is that you live in the home for at least 2 of the past 5 years. In general, you won’t qualify for the exception if you live in a property for less than 2 years unless you qualify for one of these exceptions.
Job change, illness, and unforeseen events
If you must move because of a sudden change in employment, you may qualify for a partial exclusion. To be eligible, your new job location needs to be at least 50 miles farther from your home than your old job.
For instance, if you’ve only lived in the home for 1 year but must relocate 75 miles away for a new job, you might be eligible to exclude half of the standard exclusion.
Similarly, if you sell your home to move closer to a doctor for treatment of an illness, or to care for a family member suffering from a serious medical condition, the IRS often grants a partial exclusion.
Tax preparers and financial professionals can help you document and validate the reason for your move and ensure the IRS recognizes your exception.
Divorce and marriage
If you’re getting divorced, eligibility for a Section 121 exclusion can be complicated, especially if you and your ex-spouse stopped living together but still jointly owned a property.
In this scenario, a spouse may keep a home after a divorce and want to sell it, but be unable to meet all the requirements, particularly the primary residence test.
After a divorce, you may be allowed to use imputed use and ownership when considering the eligibility requirements. That means that you can consider both your own and your ex-spouse’s ownership and residency periods.
Consider working with a tax professional who can provide you with more information on precise eligibility requirements if you are divorced and selling a jointly owned home.
Another thing to keep in mind is that if you are newly married, both spouses must meet the ownership and residency requirements to use the full $500,000 exclusion. If only one spouse qualifies, for example, because the other spouse moved in shortly before the home sale, you may only be able to exclude $250,000 in gains.
Military, foreign service, and federal extended duty
Some federal employees receive special consideration that extends the 5-year eligibility window for capital gains exclusions. Specifically, if you're serving on qualified official extended duty, you may suspend the 5-year test period for up to 10 years, giving you more time to qualify for the home sale exclusion.
Qualified official extended duty generally means you are ordered to a duty station that is at least 50 miles from your main home or are required to live in government quarters.
Federal employees who qualify for this exception include:
- Foreign service members
- Intelligence community employees
- Members of the uniformed services stationed away from home
This extension gives federal employees the flexibility to sell their homes without losing the chance to exclude their capital gains, even if they’ve been away for extended periods due to service.
Nursing home stays
A Section 121 exclusion may be possible if you fail to meet residence requirements due to moving into a healthcare facility or nursing home.
Under the rules of this exception, if you live in a home as a primary residence for at least 1 out of the past 5 years but move into a healthcare facility or nursing home due to being physically or mentally incapable of caring for yourself, you can count time spent in that facility as time spent in your home.
What if the home is a rental, second home, or investment property?
Section 121 exclusions apply only to your primary residence.
If you own a second home, rental, or investment property, you likely can’t use the exclusion to reduce the taxes you owe by selling.
However, there are other ways to reduce your tax bill.
1031 exchange for rental or investment property
If you are selling a rental home or commercial building, the 1031 exchange rule allows you to defer paying capital gains taxes by reinvesting the profits from your sale into a new property of the same nature or character.
Note that the property being sold must be held for investment or business purposes, not used as a primary residence or vacation home.
To qualify for a 1031 exchange, you must:
- Identify a replacement property within 45 days of selling the original property.
- Close on the new property within 180 days of the original sale.
- Use a Qualified Intermediary (QI) to hold and transfer the sale proceeds.
- Purchase a replacement property of equal or greater value to fully defer taxes.
Keep these limitations in mind:
- The transaction must follow strict IRS rules, including timely identification and closing.
- You must reinvest all proceeds, or the unused portion may be taxed.
- You must report the transaction to the IRS using Form 8824 during the same tax year of the exchange.
- Deferral is not permanent. Capital gains taxes will apply if you sell the new property later without another exchange.
Second homes also used as primary homes
If you own two properties, determining which home is your primary home can be complicated, especially if you owned a home as a primary residence, bought a new home, and moved while still owning your previous home.
If your second home was your primary residence for at least two out of the last five years, it can still qualify for a Section 121 exclusion. However, you should be ready to provide documentation that it was truly used as a primary residence should the IRS audit you.
Rental use, depreciation, and home offices
If you own a rental home, you can deduct many of the costs of operating the rental from your taxes. For example, you can deduct the cost of managing and maintaining the property, such as insurance, taxes, advertising, and utilities.
You also can take deductions for depreciation. Keep in mind that depreciation can reduce the adjusted basis of your home, which will increase the amount you owe in capital gains when you sell.
If you have a home office, you also can qualify for deductions depending on the size of the office and the cost of things like your mortgage and utilities.
Do you have to report the home sale to the IRS?
In general, you only need to report the sale of a home if you have taxable gains from the sale.
If you can exclude the entirety of your profit from the sale, meaning you owe no tax, you do not need to report a sale.
FAQ
Here are answers to common questions about avoiding capital gains tax when selling a home and buying another.
Do you have to pay capital gains if you reinvest in another house?
Whether you pay capital gains taxes when reinvesting in another home depends on whether you’re selling and buying investment properties or a primary home.
With primary homes, you will need to pay capital gains tax. If you’re selling and buying investment properties, you may be able to defer the gains using a 1031 exchange.
Do I pay capital gains tax when I sell my house and buy a new one?
Yes, if you sell your home for a profit and cannot exclude all the capital gains, you must pay capital gains tax, even when buying a new home.
Can I use the money from selling my house to buy another house?
Yes, you can use the money from selling your home to buy another one, though you may need to pay capital gains taxes on the profit you earned, reducing the amount you can put toward the new home.
How much time after selling a house do you have to buy a house to avoid the tax penalty?
If you are using a 1031 exchange to defer capital gains taxes, you must identify a new property within 45 days and close within 180 days of your sale.
Is there a one-time capital gains exemption for seniors or homeowners over 55?
There is no specific capital gains exemption for seniors or homeowners over 55 who sell their homes. Some areas may have exemptions or other programs that can reduce property taxes owed by seniors.
Do I pay capital gains taxes if I inherit a property?
No, if you inherit a property, you do not need to pay capital gains taxes until you sell it. In fact, you may qualify for a step-up in cost basis, increasing the cost basis of the property to its fair market value on the date you inherited it, which could reduce the tax you owe when selling.
The bottom line on avoiding capital gains taxes when selling a home
Selling a home or investment property can be a rewarding milestone. But without a clear understanding of capital gains taxes, it can also become an unexpected financial burden. As you plan your next move, it’s important to weigh all your options. No matter your path forward, taking the time to understand your capital gains exposure and exploring tax-smart strategies can help you protect your profit, plan your future, and make your next real estate move with confidence.
Ready for your next home? Explore your borrowing options today with Rocket Mortgage.
1 This article is for informational purposes only and is not intended to provide financial, investment, or tax advice. You should consult a qualified financial or tax professional before making decisions regarding your retirement funds or mortgage.

TJ Porter
TJ Porter has ten years of experience as a personal finance writer covering investing, banking, credit, and more.
TJ's interest in personal finance began as he looked for ways to stretch his own dollars through deals or reward points. In all of his writing, TJ aims to provide easy to understand and actionable content that can help readers make financial choices that work for them.
When he's not writing about finance, TJ enjoys games (of the video and board variety), cooking and reading.
Related resources

8-minute read
How to lower capital gains tax on rental property sales
Owners pay capital gains on rental properties when they sell. Learn how these taxes work and how to reduce what you owe when you sell an investment property....
Read more

8-minute read
Capital gains tax on real estate and home sales: A guide
Selling your home? Learn how capital gains tax on real estate works, how much you might owe, and strategies to reduce or avoid taxes when selling your home.
Read more

13-minute read
How to buy a house while selling yours
Learn how to buy a house while selling yours with steps to compare options, coordinate closings, and use contingencies or financing. Start planning today.
Read more