Can I offset a large capital gain on sale of a house with a capital loss in the stock market?

I sold a house in 2021. Capital gains taxes (not just gains) will be almost $500,000. If I have capital losses of a similar magniture in the same year would that negate my taxes?