Q: I want to sell my rental property, but I don’t want to pay capital gains tax.

The house used to be my primary residence until I was married. I’ve actually owned it for 15 years, but haven’t lived in it in for over 5 years.

To cut down on the taxes I’m paying, I’m considering moving back into the house for two years before selling it. My husband would stay in our current primary residence. I’d have a roommate in the rental house, but all the utilities will be in my name.

I’d live this way for two years, keeping the house as my primary residence, although I may not spend all my time there. Does this sound like a reasonable way to avoid capital gains tax?

A: While your plan sounds like a great way to avoid paying taxes, it probably won’t work.

Your primary residence is the place where you live, file income taxes and vote. Since you’re married and, presumably filing jointly, it will jump out as a red flag if you try to claim this house as your primary residence.

Instead, why don’t you consider swapping this property for another income-producing property that costs at least the same amount using a 1031 tax-free exchange. You’ll defer all of your capital gains taxes. Ultimately, you and your husband can move into the new property and declare that your primary residence.

Please consult with an attorney who has handled a number of 1031 exchanges. If you choose to go this route, there are time-sensitive rules that you wouldn’t want to break.