2 out of 5 year rule for home sale exclusion after renting it out — does my situation qualify?

Trying to figure out if I still qualify for the home sale exclusion after renting my place out for a few years. I bought the house in 2018, lived in it as my main home until early 2022, then rented it out. Just accepted an offer and I'm closing next month. I've seen the phrase "2 out of 5 year rule" thrown around but I'm not totally sure how it works when you've had renters. My total gain is going to be substantial so this matters a lot. I've been reading Publication 523 on irs.gov but the ownership vs. residence test language is a bit confusing to me. Does my rental period reset anything? And does it matter that the 2 years of residence weren't right before the sale — they ended a couple years ago?

40 comments

The residence test doesn't require that your 2 years of use be immediately before the sale. It just has to fall within the 5-year window ending on your sale date. So the question is: does the period you actually lived there as your main home add up to at least 24 months within the 5 years before closing? If your sale closes sometime in 2025 and you lived there through early 2022, that residence period is still inside the 5-year window. You likely clear the bar on the use test.

Tony A.

Author

Thanks, that's the clarification I needed. So the rental period doesn't wipe out my earlier residence time — it just sits alongside it in that 5-year window.

Worth mentioning — I went through almost this exact rental-then-sale situation last year. I uploaded my closing disclosure and prior returns to taxr.ai and had it walk through the Publication 523 eligibility test line by line against my own dates. It flagged that I'd met the ownership and residence tests but also pointed out the depreciation recapture piece I'd totally overlooked. That's a separate tax hit even if the gain is excluded, so make sure you're accounting for it.

Tony A.

Author

Wait, depreciation recapture applies even if the gain qualifies for the exclusion? I did take depreciation during the rental years.

Yes. The exclusion covers your capital gain but unrecaptured depreciation on a rental is taxed separately at its own rate — it doesn't get excluded. Publication 523 and Publication 550 both touch on this. The Schedule D instructions will walk you through the unrecaptured section 1250 gain piece.

Tony A.

Author

Okay that changes things considerably. I need to pull all my depreciation schedules before I assume my tax bill is zero.

Does the 2-year ownership test and the 2-year use test both have to be satisfied separately? I always thought they were the same thing but now I'm second-guessing myself.

They are separate. You need 24 months of ownership AND 24 months of use as your main residence, both within the 5-year period before the sale. For a joint return only one spouse has to meet ownership, but each spouse has to meet the residence requirement independently. The combined exclusion for a couple filing jointly is higher — see the Publication 523 eligibility test for the exact limits.

Have you already reported any depreciation on this property on Schedule E while it was rented? If not, you may still have deemed depreciation to deal with — the IRS treats it as if you took it even if you didn't claim it. That affects your adjusted basis when you calculate the gain.

Tony A.

Author

I did report it on Schedule E each year, so I have the records. Didn't realize it would come back to bite me on the sale side too.

It always does. Your adjusted basis going into the sale is reduced by all the depreciation you were allowed, so your gain ends up larger than just purchase price vs. sale price.

Is there a "once every two years" limit on this exclusion that could be a problem here? I think I recall reading that somewhere.

Yes — you can't exclude gain on a home sale if you excluded gain on a different home sold within the 2-year period before the current sale. That's part of the Publication 523 eligibility test. If this is the only home you've sold in the past couple of years, that rule isn't an issue.

Makes sense, good to know that's baked into the same test rather than a separate form.

What if the gain is partly above the exclusion limit? Does any excess just get reported as a regular capital gain, or is there something special about it being a former rental?

Any gain above the exclusion amount gets reported on Form 8949 and flows to Schedule D as a long-term capital gain, assuming you've held the property more than a year — which at this point seems very likely. The unrecaptured depreciation portion is carved out and taxed at its own rate, not at the lower long-term capital gains rate that applies to the rest.

When I sold a house I'd rented out for a couple of years I was nervous about whether I'd done the date math right on the 2 out of 5 year rule. I had Taxr read through my HUD-1, the lease agreements, and my prior Schedule E returns, and it prepared a worksheet showing each period of use and ownership laid out against the 5-year window — made it really easy to hand to my CPA and confirm I qualified before we filed. Helped me feel confident I wasn't missing anything.

Tony A.

Author

That worksheet idea is exactly what I need so I can show a CPA the full picture before closing. I'm going to look into that.

Are you planning to use a CPA or enrolled agent for this? With the depreciation recapture and the exclusion both in play, the numbers can interact in ways that are easy to get wrong on your own.

Tony A.

Author

Leaning toward a CPA who handles real estate sales. I wanted to understand the rules first so I'm not going in completely blind.

That's a smart approach. Knowing the difference between the exclusion and the recapture before you sit down with someone means you'll ask the right questions and catch it if something looks off.

Does it matter which months you count? Like does January through December of a year count differently from say July to June the next year?

The 24 months don't have to be consecutive and they don't have to align with calendar years. You're counting total days or months of actual use as your main home within the 5-year period. Short temporary absences count as use even during the rental window in limited cases, but extended rental is not counted as residence. Publication 523 has the details on what qualifies as use.

If you end up not quite clearing the full 24 months on the use test for some reason, there's a partial exclusion that might still apply. It covers situations like a job relocation, health issue, or certain unforeseeable events. You'd get a pro-rated portion of the full exclusion. Worth knowing about as a fallback.

Tony A.

Author

Good to have in my back pocket even though I think I clear the full test. I'll mention it to the CPA in case the date math comes out differently than I think.

Did you ever do a section 1031 like-kind exchange on this property at any point? There's a rule that can disqualify you from the home sale exclusion if the property was acquired through a 1031 exchange within a certain lookback period.

Tony A.

Author

No, I bought this outright in 2018 as my primary residence. Never used it in a 1031.

Good, that simplifies things. That rule catches people who convert a 1031 property into a primary residence and then try to use the exclusion too soon.

How does Form 8949 come into this? Do you have to report the sale even if the whole gain is excluded?

If you didn't receive a Form 1099-S, and the full gain is excluded, you generally don't have to report the sale at all. But if you did receive a Form 1099-S, you must report the sale on Form 8949 regardless. Use Part II since it's a long-term asset, check box F if the 1099-S covers it, and use code H with the excluded gain as a negative number in column (g) so the taxable portion comes out correctly.

So the 1099-S is really the trigger. Good to know — I'd assumed you always had to report it.

Does the renting-out period affect the holding period for figuring out whether the gain is long-term or short-term?

The rental period counts toward your holding period just like any other time you owned the property. Holding period starts the day after you acquired it and includes the day you sell. With a 2018 purchase date you're well past the one-year mark for long-term treatment.

What line on Schedule D does the remaining taxable gain show up on after Form 8949?

The totals from Form 8949 flow to Schedule D. Long-term amounts land on Part II of Schedule D, and the net result ultimately reaches line 7a of Form 1040. If there's unrecaptured section 1250 gain from the depreciation, the Schedule D worksheets handle the rate calculation separately — the instructions walk through that.

Something I didn't see mentioned — make sure the adjusted basis calculation also accounts for any improvements you made before or during the rental period. Capital improvements add to your basis and reduce your gain. Flooring, roof, additions — all of it. You'd want records of what you spent.

Tony A.

Author

I do have receipts for a kitchen remodel from 2020. I'll pull those together. Hadn't thought about improvements reducing the gain on top of everything else.

Has anyone here dealt with a situation where the rental period was long enough that the 5-year window didn't reach back to the years of residence? That seems like the edge case that could really hurt someone.

That's the real trap. If you rent for more than 3 years before selling, the 5-year lookback might not stretch back far enough to include your 2 years of residence, and you lose the exclusion entirely. That's why the timing of the sale matters — waiting too long after converting to a rental can cost you the exclusion even if you once legitimately lived there.

Tony A.

Author

This is exactly why I'm selling now rather than waiting another year. I wanted to make sure I was still inside that window.