If the property is a rental property that you’re not living in, it doesn’t qualify for the capital gains exclusion. However, if you have a multiunit primary property and you’re living in one unit, that does qualify.
Even with investment properties, there may be other tax advantages that you qualify for. You can use a 1031 exchange to defer taxes on capital gains from the sale of an investment property as long as those gains are put toward the purchase of another investment property. Additionally, you may be able to defer capital gains on property in opportunity zones. Talk to your tax advisor.