The worst states for retirees, according to WalletHub’s annual ranking, were among the most expensive in the country, a factor that couldn’t be overcome by strong rankings for health care or quality of life.

For example, even though Hawaii ranked No. 1 for life expectancy, it also had the highest adjusted cost of living (and you could do worse than Hawaii, although according to WalletHub, not much worse).

(Click here to compare this year’s list to the worst states last year.)

Jim Mitchell, professor of sociology and director of the Center for Diversity and Inequality Research at East Carolina University, urged caution to retirees who are unhappy in their current home and considering a move. The most common mistake retirees make, he said in the report, is “failure to carefully weigh the pros and cons of staying in their present homes. For many, home equity is a significant asset, and the risks and benefit of relinquishing that asset should be considered carefully in light of replacement costs.”

He also warned against choosing a new home with a “vacation mentality,” and recommended that retirees pay attention to the “availability and accessibility of affordable assistance and transitional housing options.” With longer life expectancies, many retirees may well be planning for retirements that will last a couple of decades. They should anticipate what they’ll do when their “retirement home” no longer meets their needs.

For example, Mitchell said in the report, “Years ago, we interviewed retirees living in houses elevated to survive hurricane-driven storm surges. When asked how they would be able to access their homes in the event of injury or disability, they tended to dismiss that possibility, and only few carefully considered options.”

WalletHub compared the affordability, health care and quality of life in all 50 states, as well as Washington, D.C. A state’s affordability, which accounted for 40% of its overall ranking, was based on cost of living and general tax friendliness, as well as taxes on pensions and Social Security income in particular and the annual cost of home care services and adult day care.

Quality of life represented 30% of a state’s score and was based on the population of people 65 and older; the labor market and poverty level for people over 65; access to public transportation; weather, museums, theaters and golf courses per capita; opportunities for volunteering; air and drinking water quality; violent and property crime rates; and the state’s elder abuse protections. The weather and elder abuse metrics were based on other WalletHub rankings.

Health care accounted for the remaining 30% of a state’s score and included measures of the physicians, nurses and dentists per capita; health care facilities and hospitals; emotional health; life expectancy; death rate for the 65-plus population; and the share of the population in good health, with health insurance, with a disability or who were physically active.

Data came from a multitude of government and other sources, including the U.S. Census Bureau, FBI, Council for Community and Economic Research, U.S. Bureau of Labor Statistics, Retirement Living Information Center, Genworth Financial, United Health Foundation, County Health Rankings, Measure of America, Centers for Disease Control and Prevention, Centers for Medicare & Medicaid Services, Charity Navigator, Gallup Healthways, GolfLink and WalletHub’s own research.

Check out the 15 best states to retire in for this year.

Here are the 15 worst states for retirement in 2017, according to WalletHub:

Baltimore Inner Harbor.

37. Maryland: 55.73

  • Affordability rank: 39
  • Quality of Life rank: 21
  • Health Care rank: 27

North Dakota welcome sign.

38. North Dakota: 55.09

  • Affordability rank: 43
  • Quality of Life rank: 42
  • Health Care rank: 6

Downtown Wheeling, West Virginia.

39. West Virginia: 54.48

  • Affordability rank: 13
  • Quality of Life rank: 44
  • Health Care rank: 48

City Hall of Jackson, Miss. (Photo: AP)

40. Mississippi: 54.48

  • Affordability rank: 8
  • Quality of Life rank: 49
  • Health Care rank: 51

Times Square, New York City.

41. New York: 53.54

  • Affordability rank: 46
  • Quality of Life rank: 1
  • Health Care rank: 30

Little Rock River Market District (Photo: AP)

42. Arkansas: 53.45

  • Affordability rank: 17
  • Quality of Life rank: 48
  • Health Care rank: 45

Kentucky Derby at Churchill Downs. (Photo: AP)

43. Kentucky: 53.27

  • Affordability rank: 16
  • Quality of Life rank: 45
  • Health Care rank: 49

Skier on the slopes at a Killington Resort. (Photo: AP)

44. Vermont: 52.79

  • Affordability rank: 48
  • Quality of Life rank: 10
  • Health Care rank: 12

Church of San Felipe in Albuquerque.

45. New Mexico: 52.61

  • Affordability rank: 36
  • Quality of Life rank: 41
  • Health Care rank: 39

Atlantic City Beach.

46. New Jersey: 52.55

  • Affordability rank: 41
  • Quality of Life rank: 27
  • Health Care rank: 35

Waikiki shoreline in Honolulu.

47. Hawaii: 51.85

  • Affordability rank: 50
  • Quality of Life rank: 34
  • Health Care rank: 3

A statue of the Spirit of Victory in Bushnell Park in Hartford. (Photo: AP)

48. Connecticut: 51.34

  • Affordability rank: 49
  • Quality of Life rank: 13
  • Health Care rank: 15

Washington, D.C. Skyline.

49. Washington, D.C.: 50.96

  • Affordability rank: 44
  • Quality of Life rank: 51
  • Health Care rank: 9

Crabbers on the fishing grounds in southeast Alaska. (Photo: AP)

50. Alaska: 50.82

  • Affordability rank: 38
  • Quality of Life rank: 50
  • Health Care rank: 34

Castle Hill Lighthouse in Newport.

51. Rhode Island: 43.84

  • Affordability rank: 51
  • Quality of Life rank: 46
  • Health Care rank: 29

— Related on ThinkAdvisor: