If you read the IRS publication it says new home has nothing to do with capital gain on sale of your current home.
Basically, lets say you purchased your current house for 100k. You're selling it for 400k.
Difference is 300K minus 250K tax exemptions (1 person) minus sale costs 25K(real estate agent fees, surveys, inspections, etc).
In that case your taxable amount is 25k.
As long as difference between sale and purchase is bellow 250k (or 500k if married), you don't have to worry about capital gain.