In hot real estate markets all over the country, homeowners are feeling stuck: They know they can get top dollar if they sell their home, but fear they will have no place to go if they leave.

The concern: An ongoing shortage of available homes for sale in cities like San Francisco, Los Angeles, Boston, New York and Washington, D.C., has made it extremely difficult for buyers to find homes they want to move into -- or can afford.

"One of the things we hear all the time is, 'I'm afraid to sell my house because I can't find another one," said Glenn Kelman, CEO of real estate brokerage firm Redfin.

And the competition for the homes that are available is so intense that buyers need to bring plenty of cash to the table. In fact, all-cash deals hit a record 43% of home sales in the first quarter of this year, according to RealtyTrac.

Tim Trampedach, a 36-year-old business owner who lives in San Francisco, has seen his home's value soar from $1.2 million to $1.6 million in the past three years. He and his wife want to move into a bigger place, but there are simply no homes within their price range in their Portrero Hill neighborhood.

"My wife and I are effectively locked into the house," he said. "We can't sell because we can't afford anything else nearby."

Related: Priced out: 'I can't afford a home in my town'

San Francisco is one of the most extreme examples. The number of homes for sale fell by more than 8% year-over-year in March, while listing prices soared 11.5% to a median of $867,000.

When inventory shrinks and prices move higher, it makes it even more difficult for a buyer to upgrade to a larger home. And if they can't buy, they can't sell, reducing the number of lower priced, starter homes.

"It's people like us, who live in a fully turnkey home, who can't supply homes because we have nowhere else to go in the city," said Trampedach.

Three thousand miles away, Kathleen Jackson has wanted to sell her South Boston home for three years. With two young children and a third on the way, her family has outgrown their small two-bedroom home.

But she has found few listings, even outside of Boston.

Related: Was my home a good investment?

In fact, demand is so high that real estate agents are actively seeking people who are willing to sell. "You get letters in the mail asking if you're interested in selling," said Jackson. "People knock on your doors."

In mid-April she got an enticing, unsolicited offer on the house, which Zillow estimates to be worth $420,000.

"My husband and I talked it over," she said. "We hemmed and hawed. It was too good to be true, but we worried: Would we find a house we wanted?"

The buyer agreed to give the couple until October to find a new place, so they took the offer.

One way sellers can protect themselves is to make the sale of their home contingent upon their ability to find another one to move into.

Patrick Matson and his fiance, Margarita Munoz, insisted on such a clause when they put their Anaheim, Calif. home up for sale. Up until last Friday they had an offer on their home, but their own search did not go well.

Related: How far will my salary go in another city?

The couple had made offers on two homes in La Mirada, where they liked the school district for their four-year-old son. But both offers were rejected.

The homes they looked at were between $430,000 and $480,000, but were no bigger or better than their current place, which they listed for $415,000.

Discouraged, the couple decided to reject the offer and take their home off the market.

"It was not an easy decision to make, provided that we knew the folks who had an offer in on our home were going to be disappointed and it wasn't what we wanted either," said Matson.

The couple plans to make some upgrades to their current place and will try again in a year or two, he said. "Hopefully the market won't be so competitive by then."