Teachers’ salaries have been rising in California, but not nearly fast enough to keep up with soaring housing prices, according to a new analysis that could shed some light on one reason why the Golden State is having trouble finding enough qualified educators for its public school classrooms.

Redfin, a national real estate brokerage, examined California’s 31 most-populous counties, from Sonoma Valley wine country in the north to the agricultural towns of the Central Valley to the sprawling metropolis of Los Angeles to the south. Just 17 percent of homes for sale in those counties were affordable on the state’s average teacher salary of $73,536, Redfin found.

That’s a marked decline from 2012, when 30 percent of homes for sale in those counties were affordable on the average teacher’s salary at the time: $70,487. “Affordable” means the monthly mortgage payment would eat up less than 30 percent of a person’s gross monthly salary.

Lindsay Katz, a Redfin agent in the San Fernando Valley, said one of her clients is a teacher who lives an hour from her school and wants to move closer. But she hasn’t been able to find anything affordable. It’s hard to find any home under $400,000, Katz said: “It’s a tough market. … Everything that’s in the lower price range you have to compete with developers who come in with all-cash offers. You keep getting beat out.”

The outlook is bleakest for teachers in Silicon Valley, home to countless tech millionaires — and billionaires — whose money has transformed the housing market. In San Mateo and Santa Clara counties, exactly zero homes for sale on Sept. 6 — the day Redfin chose for its analysis — were affordable for the average teacher. Things weren’t much better in nearby San Francisco (where 1 of 571 homes for sale were affordable for teachers), Sonoma or Santa Cruz.

Teachers willing to move to less-fashionable parts of the Golden State have better prospects. In Fresno, for example, real estate is relatively cheap and teachers are well-paid; the average teacher could afford a $320,000 house, which — according to Redfin — “easily buys three bedrooms and 2,000 square feet on a large lot.”

The study is only a snapshot, of course, and perhaps if Redfin’s economists had chosen a different day to sample, things might have looked a little rosier. But the problem of out-of-reach housing costs is real for teachers not just in California, but also in other expensive parts of the country.

A growing number of California teachers have started driving for Uber on weekends and in the evenings, the Nation reported this month. In San Francisco, the average teacher would have to spend two-thirds of her salary to afford the city’s astronomical median rent of $3,500, according to the San Francisco Chronicle. The paper profiled several teachers who fled the city because of the housing crunch, including Emilee Hanson, who was renting a room in San Francisco for $700 per month before decamping to rural El Dorado County, where she was able to buy a house on five acres for $200,000.

Taking heed, some districts (including San Francisco) are working to build or provide affordable, below-market-rate housing for employees. The Learning Policy Institute, a think tank headed by Stanford professor Linda Darling-Hammond, recommended housing incentives as a tool for the many districts that are struggling to fill teaching vacancies. Enrollment in teacher training programs has dropped 70 percent during the past decade, according to the institute, and the supply of new teachers in California is at a 12-year low.