2021 saw double the number of ZIP codes with a median sales price above $3 million than in 2020. As real estate prices continue to rise, investors wonder if targeting more expensive areas is worth the reward.

Generally speaking, expensive real estate results in higher rents, but that doesn't always equate to higher returns for real estate investors. Here's a look at some of the most expensive areas in the country and how these expensive ZIP codes stand up as a rental investment.

The most expensive real estate in the United States

California typically holds the title of most expensive real estate in the United States, with 38 out of the top 50 most expensive ZIP codes falling within its borders. New York ranks second, holding nine of the 50 ZIP codes. That leaves the other 13 ZIP codes scattered across the country, including several places like Medina in Washington state; Gibson Island in Maryland; and Boston.

Expensive condo living room and office.

Image source: Getty Images.

The most expensive ZIP code in the U.S. is 94027, or Atherton, California. The second most expensive is Boston's 02199, with an average price per square foot of $1,800. This exclusive high-rise neighborhood located just down the street from the Boston Common makes the rest of the city seem like a steal of a deal. For perspective, the neighboring ZIP code of 02118 in Boston is only an average of $1,100 per square foot.

Fisher Island, just off of Miami, is in the same boat. The average price per square foot in this little oasis of 33109 is $2,000, when the real estate just across the cut in Miami Beach, or 33139, goes for around $577, nearly a quarter of the price.

Do rental properties make sense in these ZIP codes?

Let's take a look at a real-time example of potential costs versus rental income for one of these expensive ZIP codes. The ZIP code of 02199 is the second-most expensive market in 2021 and primarily consists of high-end condos. The average sales price for a two-bedroom, two-bath 1,500 square foot condo is around $2.7 million. With a 20% down payment and a 30-year fixed-rate mortgage at 4%, the monthly mortgage payment will be a hair over $10,312.

The average rent for a comparable condo is $6,454, which isn't even enough to cover the mortgage. On top of the $3,858 deficit between the rent and the mortgage, the landlord would also be responsible for holding costs such as property taxes, rental insurance, property management, HOA fees, and repairs. Even as a vacation rental, it's a hard sell considering rental rates are $139 a night, at most netting $4,170 a month. In this scenario, the only way the rental property would produce a positive cash flow is if it was purchased with cash, providing an annualized return of 2%, a pretty measly return considering that the same $2 million could likely receive double-digit returns in the stock market with further diversification.

When rentals in expensive areas make sense

It's one thing if the real estate you're buying is to visit as a vacation property once a year or something you intend on retiring to. That creates a scenario where you're looking at personal desires more than just the numbers. If you have an inheritance in one of these exclusive areas and are just looking to generate some passive income, then it could make sense to keep the property as a rental.

Likewise, if you are in a position to purchase the property with cash or want to use a 1031 exchange to avoid capital gains taxes, it could make financial sense. In addition, if you are looking to transfer some of your wealth into real estate as a hedge against inflation or you're anticipating significant appreciation, then this investment might also make sense.

When rentals in expensive areas don't make sense

For the majority of real estate investors, it is very likely that holding a rental in an expensive ZIP code will not add up financially. If you have to hold a large mortgage like in the scenario above, the holding costs will far surpass the income. In most scenarios, it won't even pay the mortgage, let alone turn a profit.

The term "expensive" is relative. What may seem costly to one investor may be a steal to another, depending on personal income and markets the investor currently operates in. There are several moderately priced markets that may seem expensive to some but still provide enough cash flow to cover a mortgage and holding costs. That's why it's important to run the numbers for each area to help you get a handle on when and where it might make sense for you.