Retiring near the beach may sound ideal, but there's more to consider than just sun and sand.

In fact, in a recent ranking of the best cities to retire, Pittsburgh claimed the top spot.

Although Pittsburgh scored poorly for weather, the metro area's low crime rate and cost of living helped pull it to the top. The former steel city turned tech powerhouse also boasts top-notch health care at the University of Pittsburgh.

To find the best places to retire, Bankrate.com assessed 50 U.S. metro areas, comparing factors including weather, health-care quality and affordability, cost of living, crime rate, taxes, senior well-being, friend factor (percentage of population ages 65-plus), cultural vitality and public transportation.

After working for decades, you may be tempted to find the most tropical, relaxing destination on the map. But it's important to look beyond climate to lifestyle and financial factors like health-care costs, which can be one of the biggest expenses for retirees, said Bankrate.com analyst Taylor Tepper.

"It's like that saying, 'don't go into a grocery store hungry,'" Tepper said.