In these 4 cities, renting long-term can cost you over $2 million

How much more it costs to own vs. rent in your state
How much more it costs to own vs. rent in your state

Home-ownership is an essential part of the American dream, yet rising home costs and widespread student loan debt make renting the only feasible option for many. Still, it can make both emotional and financial sense to keep the dream of owning alive since, according to a new report from GoBankingRates, renting can cost you millions over the course of your working life — especially if you're on the West Coast.

California and Washington are the two states where it's the most expensive to rent an apartment over the long-term: The costs in some cities there can add up to over $2 million if you start at 25 and end at 60.

San Francisco proves to be the most costly city in which to rent over a 35-year period: GoBankingRates estimates it could cost nearly $2.5 million. That's far more than the current median home price of $1.6 million, according to Curbed.

Los Angeles comes in second, with a total rent tab of $2.2 million. Seattle, Wash., and San Jose, Calif., round out the top four, with 35-year rent costs of $2.1 and $2 million, respectively. By contrast, in Detroit over the same time period, you'd spend only $502,740.

GoBankingRates bases its rent cost calculation on Zillow's published median rental prices from February 2017 to 2018. From there, the company extrapolates the year-over-year increase out over a 35 year period to determine the total rental costs that would accrue by the time a person turns 60. This, of course, assumes that rental prices will continue to climb at the current rate over the next 35 years.

It's worth noting that renting offers distinct advantages, and owning can also come with plenty of hidden costs.

Still, if you want to buy, you may be able to even if you don't have the money for a down payment of 20 percent. The first step is to figure out where you stand. "It's really good to have a handle on your personal finance situation," AJ Smith, VP of financial education at SmartAsset, tells CNBC Make It. "What your budget looks like, what you feel comfortable with, what not having that 20 percent down will do to your monthly mortgage payments."

In the meantime, make sure you're not overspending on rent, if you can help it. The general rule is that you should try not to put more than 30 percent of your monthly gross income towards housing. If you're debt-free, though, money expert David Bach says you can afford to spend up to 41 percent.

Don't miss: Here's why renting—instead of owning—a home may be a smart money move

Like this story? Like CNBC Make It on Facebook!

The biggest mistake millennials are making is not buying a home, says financial expert
The biggest mistake millennials are making is not buying a home, says financial expert