The property was not originally purchased with funds from a 401k/retirement account.
There is no deferral of a capital gain. Deferring more of your compensation to a traditional 401(k) simply reduces taxable income. That doesn't change how much of a capital gain is includible in income, but a reduction in taxable income it could reduce the tax rate that applies to your capital gain if the capital gain is long-term.
It's a bit late in the year to alter your deferral to a 401(k) unless you are self-employed and elect a one-time 401(k) deferral. Unless 2023 would be the first year for a solo 401(k), the deadline to make the deferral election is year-end 2023.
Thank you for the reply! This is helpful. In this specific scenario, I have not made any contributions to my 401k this year. With the sale of the investment property, I have a capital gain tax liability of about $400k. If I contribute the max annual contribution to my 401k ($30k, I am well above 50 years old) for 2023, will I be deferring/reducing the capital gain tax liability from the sale of the investment property? Ex. $400k from sales proceeds - $30k contribution to 401k = $370k capital gain tax liability for 2023. Hope my question makes sense and thank you in advance.