Wash sale rule and retirement accounts: IRA, 401(k), and Roth
Most investors know the wash sale rule prevents you from claiming a loss if you rebuy the same security within 30 days. What many don't realize is that rebuying in a retirement account doesn't just defer the loss. It destroys it permanently.
Disclaimer: This article is for educational purposes only and does not constitute tax or financial advice. Consult a qualified tax professional for guidance specific to your situation.
Quick recap: how the wash sale rule works
The IRS wash sale rule (IRC Section 1091) disallows a capital loss deduction when you buy a substantially identical security within 30 days before or after the sale. That's a 61-day window total: 30 days before the sale, the day of the sale, and 30 days after.
In a taxable brokerage account, the disallowed loss isn't gone forever. It gets added to the cost basis of the replacement shares, which means you'll eventually benefit from it when you sell those replacement shares later. The loss is deferred, not eliminated.
For a complete overview, see our guide to the wash sale rule explained.
Why retirement accounts are different
In a taxable brokerage account, cost basis matters. When you eventually sell the replacement shares, the higher cost basis reduces your capital gain (or increases your loss). The tax benefit is postponed, but it's still there waiting for you.
Retirement accounts don't work this way. Traditional IRAs, 401(k)s, and similar accounts don't track individual cost basis in the same meaningful way. When you take distributions from a traditional account, the entire withdrawal is taxed as ordinary income regardless of what you originally paid for the shares inside. The cost basis of individual holdings is irrelevant to your tax bill.
Roth accounts flip the equation but arrive at the same conclusion. Qualified Roth withdrawals are completely tax-free, so the adjusted cost basis has no effect on your taxes in that direction either.
This means the adjusted cost basis from the wash sale has nowhere to go. It sits inside an account where it will never provide a tax benefit, no matter how long you wait or when you withdraw.
This is the critical distinction: a wash sale between two taxable accounts defers your loss. A wash sale involving a retirement account permanently eliminates it. The deduction is gone, and no future transaction will bring it back.
How it works for each account type
Traditional IRA
Consider this example. You hold 100 shares of XYZ in your taxable brokerage account with a cost basis of $50 per share. The stock drops, and you sell all 100 shares at $40 per share, creating a $1,000 capital loss. Within 15 days, you buy 100 shares of XYZ at $42 in your traditional IRA.
The $1,000 loss is disallowed under the wash sale rule. Normally, this loss would be added to the cost basis of the replacement shares, bumping your per-share basis from $42 to $52. But when you eventually withdraw from the IRA years later, the entire distribution is taxed as ordinary income. The $10 per share cost basis adjustment is meaningless because the IRA doesn't care what you paid for any individual holding.
Net result: you permanently lost a $1,000 tax deduction.
Roth IRA
The same mechanism applies. The cost basis adjustment is trapped inside the Roth, where it provides even less theoretical benefit. Since qualified Roth withdrawals are tax-free in retirement, there is no scenario where a higher cost basis reduces your tax bill. The loss simply vanishes.
401(k) and 403(b)
The same principle applies as with a traditional IRA for pre-tax contributions. But 401(k) plans introduce an additional risk that's easy to overlook.
If your 401(k) plan holds the same fund you sold at a loss in your taxable account, automatic payroll contributions could trigger a wash sale without you even realizing it. Every pay period, your contribution buys more shares, and if those shares are in the same fund you just sold at a loss, you have a problem.
Employer matching contributions that purchase the same fund could also create a wash sale. The IRS looks at all acquisitions of substantially identical securities across your accounts, not just the purchases you deliberately make.
HSA (health savings account)
Health savings accounts are often overlooked in wash sale planning. If your HSA is invested in individual stocks or funds (not just sitting in cash), and you hold the same security you sold at a loss in your taxable account, the same wash sale rules apply.
HSAs have a well-known triple tax advantage: contributions are tax-deductible, growth is tax-free, and qualified withdrawals are tax-free. But that advantage does not protect you from the wash sale rule. A repurchase inside an HSA within the 61-day window will disallow your loss just like any other retirement account.
Scenarios that catch investors off guard
Automatic contributions buying the same fund
Regular 401(k) or IRA contributions set to auto-invest in a specific fund can trigger a wash sale if you sell that same fund at a loss in your taxable account. Even a small automatic purchase within the 30-day window is enough to disallow the entire loss (up to the number of shares repurchased).
Here's a common example. You decide to sell your S&P 500 ETF at a loss in your brokerage account as part of a tax-loss harvesting strategy. Meanwhile, your 401(k) has been set to purchase an S&P 500 index fund with every payroll contribution, which happens every two weeks. The next payroll contribution lands 10 days after your sale. Wash sale triggered, and the loss (proportional to the shares bought) is permanently disallowed.
Target-date funds holding the same underlying security
This is a grey area. If your 401(k) holds a target-date fund that in turn holds the same stock or ETF you sold at a loss, does that trigger a wash sale? The IRS has not explicitly addressed this question. Most tax professionals consider it unlikely because you're purchasing a different security (the target-date fund itself, not the underlying holding). However, the question hasn't been definitively settled in IRS guidance or court decisions, so some uncertainty remains.
Spouse retirement accounts
The IRS has historically applied the wash sale rule to spouses when filing jointly. If your spouse buys the same security in their IRA within the 30-day window, your loss can be disallowed. This includes automatic contributions to their retirement accounts. If both of you hold similar investments, coordinating tax-loss harvesting across both sets of accounts becomes important.
How to avoid the retirement account trap
Before harvesting losses in your taxable account, check what your retirement accounts hold. If any of them hold the same security, pause automatic contributions for that specific fund during the 61-day window (30 days before and after the sale).
Another approach is to switch to a different (but not substantially identical) fund in your retirement account before you sell in your taxable account. For example, if you plan to sell an S&P 500 ETF at a loss, move your 401(k) allocation from the S&P 500 fund to a total market fund first. Make the switch well before the 61-day window begins.
The simplest option is to wait. If you avoid repurchasing in any account for 31 days after the sale, the wash sale rule does not apply, and you can claim the full loss.
Finally, keep a record of which securities are held in each account. A consolidated view of your portfolio across all accounts makes this much easier to manage. For more on loss harvesting strategies, see our tax-loss harvesting guide for US investors.
How TrackMyShares helps
TrackMyShares lets you create a consolidated portfolio that combines holdings from multiple individual portfolios. This gives you a single view of every security you hold across accounts, making it easier to spot potential cross-account wash sale conflicts before they happen.
The wash sale detection feature scans for purchases of the same symbol within the 61-day window. When you set up a consolidated portfolio, this detection works across all the underlying portfolios, so you can see if a purchase in one account would trigger a wash sale from a sale in another.
Note that the detection covers exact symbol matches only. If you're concerned about substantially identical securities across accounts (for example, two different S&P 500 ETFs from different providers), you'll need to evaluate that yourself. Our guide on substantially identical securities can help with those judgement calls.
Retirement accounts are powerful tools for building wealth, but they can create an expensive trap when combined with tax-loss harvesting. Taking a few minutes to review your holdings across all accounts before selling at a loss can save you from permanently losing a deduction you'll never get back. Sign up for TrackMyShares to track your holdings across accounts and stay ahead of wash sale risks.