If you're selling your home - you can avoid taxes using primary residence exemption. You don't need to buy any new home instead.
If the home you're not selling is not your primary residence, and hasn't been for at least 2 years of the last 5, then you cannot avoid capital gains. You can defer them, using 1031 exchange. Note that you'll still be paying taxes on the capital gains, just not right now. You'll be paying them when you sell the asset you bought as an exchange (your gains will reduce your basis in that asset).
However, you cannot use 1031 exchange if you're exchanging a property in the US with a property in another country. 1031 is only used for like-kind assets, and the IRS explicitly says that assets in the US are not like-kind to assets outside of the US:
One exception for real estate is that property within the United
States is not like-kind to property outside of the United States