San Francisco is such a boomtown that people are leaving in droves.

In 2016 and 2017, more people moved out of the San Francisco-Oakland-Hayward metropolitan area—an urban core of 4.7 million people in a broader region known as the Bay Area—than moved into it from other parts of California or the U.S., according to U.S. census data.

In the year that ended July 1, the region showed a net loss of nearly 24,000 residents to the rest of the country, roughly double the loss of the previous year and a sharp reversal from net annual gains of about 15,000 as recently as 2013-14.

Economists said the outflow is being driven by the high cost of housing in the area, where the average home value in several counties surpasses $1 million. Thanks to immigration and more births than deaths, the overall population still grew 0.6% last year, but that was less than the national rate of 0.7%.

The ripple effect of explosive growth is a familiar theme in Northern California, where the rise of the world’s tech capital, Silicon Valley, reshaped a vast region.