Priciest housing markets getting further out of reach

Fewer median home buyers can afford houses in the least affordable cities

If interest rates rise, so will the cost of buying a house, pushing some would-be homebuyers to the sidelines.

Many of those home shoppers are already getting priced out, as the full cost of homeownership chews up a bigger share of the median household's monthly paycheck, according to an analysis of homeownership costs by real estate site Trulia.

Most housing affordability measures look only at direct costs of ownership such as mortgage payments, taxes and insurance. But homeowners still have to pay monthly utility bills and get to work every day. When those costs are accounted for, the numbers look a lot different, according to Trulia's data.

"When we took these two nonhousing, essential costs into account, we found that some of the most affordable markets don't look that cheap anymore," said Ralph McLaughlin, a Trulia economist who crunched the numbers.

To assess the full cost of buying a new home, the Trulia analysis looked at the median household income in the 100 largest metro areas and measured how big a share of each monthly paycheck would be needed to buy a median-price home in that metro, based on listing prices. They ran the numbers based on a 30-year fixed-rate loan at 4 percent, and added in property taxes and insurance.

But then they added in the median household spending on electricity, gas and water for that metro (based on Census data), along with an estimate of commuting costs. When those expenses are accounted for, a lot of metros look a lot less affordable.

Most guidelines, including those set by the government, consider a house to be "affordable" if the cost of keeping up with mortgage, taxes and insurance amounts to roughly a third of your monthly income. By that measure, there are still plenty of "affordable" metro markets.

A median income home buyer in Detroit, Michigan, or Birmingham, Alabama, for example, can expect to spend less than 20 percent of their monthly income on direct housing costs on a median-price home. But when you factor in commuting and utility expenses, homeownership would eat up nearly 40 percent of the median paycheck. In relatively affordable Houston, direct housing costs are about 35 percent of income, but they jump to 50 percent with utilities and commuting included.

The analysis confirms that housing is most affordable in the middle of the country and least affordable on the coasts. But the gap between these markets is amplified when the full cost of home buying is accounted for.

In Akron, Ohio, for example, the median household income of less than $46,000 will easily pay for the median-priced home of $120,450. About 16 percent of your paycheck would go to direct housing costs, 8 percent for your commute and another 5 percent for utilities.

In San Francisco, on the other hand, a buyer with the median income of a little over $65,000 can expect to spend 77 percent of his or her monthly paycheck to buy the median-priced $1.2 million home. Add in utilities and commuting, and you'll burn through 85 percent of your monthly income.

"The least affordable housing markets in the country tend to be big cities, and they also tend to be in areas with a decent climate," said McLaughlin.

Aside from attracting more buyers, cities with good climate tend to have lower utility bills because it costs less to heat in the winter or keep cool in the summer. And big cities are more likely to have better options for public transportation, which is usually a cheaper way to get to work.

Read MoreWhat happens to housing if mortgage rates go to 6 percent?

With incomes rising more slowly than home prices in the last year, the toughest markets for median income homebuyers are getting even further out of reach. In San Francisco and Miami, for example, the share of income needed to buy a house jumped more than 15 percentage points in the year ended in August, according to the analysis.

"In general, the most expensive markets are actually getting less affordable and the most affordable are remaining stable," said McLaughlin.