U.S. military veterans are finding that homebuying can be a real battle. They have to contend with rising prices, tight supplies of homes for sale, and competing buyers who can make all-cash offers.

Only 9% of typical houses on the market in the nation's largest metro areas are affordable for veterans, says real estate website Redfin. That's down from 27.4% in 2012.

If you're out of the military and looking to take advantage of the very attractive VA home loan program, Redfin says these 10 markets are your best bets, counting down to the most affordable.

10. Birmingham, Alabama

Birmingham, Alabama, USA city skyline.
Sean Pavone / Shutterstock

In the Birmingham metro area — best known for its civil rights history and steel making — 19.2% of homes for sale are affordable for veterans, says Redfin.

That's based on the local median income for vets of $36,780 a year, and the area's median asking price for homes of $239,900.

Here's another plus for veterans in Birmingham: Its VA Medical Center gets 4 out of a possible 5 stars from the Department of Veterans Affairs, which says the facility has been showing improvement.

Find a Lender: Check your eligibility with Veterans United Home Loans.

9. Washington, D.C.

Washington, D.C. skyline with highways and monuments.
Sean Pavone / Shutterstock

In the D.C. metro area — which is home to many retired officers and several military bases, not to mention the Pentagon19.6% of typical homes on the market are affordable for veterans.

That's owing to the median income of $73,435 for vets in the region, and the median price of $490,000 for homes listed for sale in Washington and its Virginia and Maryland suburbs.

But Washington's VA Medical Center is not one of the better ones. It scores 2 out of 5 stars and has not been getting improving much, says the Department of Veterans Affairs.

8. Pittsburgh

Rachel Carson Bridge (aka Ninth Street Bridge) spans Allegheny river in Pittsburgh, Pennsylvania
mandritoiu / Shutterstock

A veteran looking through real estate listings in Pittsburgh — a sports fan's haven thanks to the presence of the Pirates, Steelers, Penguins and Pitt Panthers — would find 19.7% of homes are affordable.

While vets in the metro area earn a median of just $33,437 a year, homes are relatively inexpensive. The median asking price is $189,900.

The VA Pittsburgh Healthcare System rates 4 out of 5 stars, and its quality has been consistent in recent years.

7. St. Louis

st. louis arch
James Roblee / Shutterstock

In St. Louis and its suburbs — a region known for baseball, blues and the iconic Gateway Arch on the Mississippi River — 21.8% of homes on the market are affordable for veterans.

That's based on the region's median annual income for veterans of $38,830, and the median list price for homes of $209,900.

As for the local VA Medical Center, it scores just 2 out of 5 stars, though the Department of Veterans Affairs says it has seen modest improvement.

6. Baltimore

Colorful row houses along Guilford Avenue in Charles Village, Baltimore, Maryland.
Jon Bilous / Shutterstock

Of the homes typically for sale in Baltimore, 22.1% are affordable for veterans.

Vets in the "Charm City" known for its crabs and row houses earn a median of $49,393 a year. The median price for homes on the market here is $339,000.

Baltimore's VA Medical Center earns 3 out of 5 stars and is said to be showing "large improvement."

5. Detroit

Detroit, Michigan USA, May 2, 2018, Detroits Renaissance Center and GM World Headquarters from a distance looking down Jefferson Avenue from high up.
Linda Parton / Shutterstock

In the Detroit metro area, veterans can afford 22.3% of houses on the market.

In this industrial city that's famously north of Canada across the Detroit River, the median income for vets is $37,527, while the median list price for homes is $264,900.

Though officials say the Detroit VA Medical Center has been making big improvement, it's still rated a 2-star facility by the Department of Veterans Affairs.

4. Louisville, Kentucky

LOUISVILLE, KY, USA - FEB 5, 2017: Sunrise at the Louisville KY Waterfront Park Wharf and the KFC Yum! Center. The wharf is home to the Belle of Louisville Steamboat.
Thomas Kelley / Shutterstock

A veteran who wants to buy a house in the Louisville metro area would find 25.3% of homes for sale are affordable.

That's based on median income for veterans of $35,958, and the median asking price of $269,900 for homes in this area known for horse racing and baseball bats. (Think Louisville Slugger.)

Find a Lender: Check your eligibility With Veterans United Home Loans.

The Louisville VA Medical Center rates 3 out of 5 stars, and its quality is said to be improving — a little.

3. Indianapolis

indianapolis,indiana,usa-09-13-17, beautiful indiannapolis skyline with reflection on water.
Checubus / Shutterstock

In the home of auto racing's iconic Indianapolis 500, 26.0% of typical houses on the market are affordable for veterans.

Vets here earn median income of $37,154 a year, and the median list price for houses is about $267,100.

The Richard L. Roudebush VA Medical Center in Indianapolis scores a 3-star rating from the Department of Veterans Affairs and is said to be showing modest improvement.

2. Memphis, Tennessee

MEMPHIS, TENNESSEE - AUGUST 25, 2017: Blues Clubs on historic Beale Street at twilight.
Sean Pavone / Shutterstock

In Memphis — a Mississippi River city best known for barbecue and the blues clubs on Beale Street — veterans can afford 36.3% of houses on the market at any one time.

That's owing to the local median income for vets of $38,008 a year, and the median asking price for homes, which is $193,500.

One of the region's negatives for veterans is the Memphis VA Medical Center, rated just a 1-star facility and showing only meager improvement.

1. Virginia Beach, Virginia

Sundown on the Chesapeake Bay with the Chesapeake Bay Bridge seen. Virginia Beach Side.
JoMo333 / Shutterstock

Virginia Beach is the nation's best market for veteran homebuyers, according to Redfin. Vets would find 38.1% of houses on the market affordable.

Military bases in the area represent virtually all branches of the service, helping to make it the "perfect" location for veterans who want to buy homes, says Redfin Virginia Beach agent Jordan Hammond.

"Not only is it close to the water and the nation’s capital, but it offers a much lower cost of living than California, where many are moving from," Hammond says.

The local median annual income for vets is $49,517, and the median list price for homes is $275,000. The nearby Hampton VA Medical Center gets 2 stars from the Department of Veterans Affairs.

Follow us on Twitter: @moneywisecom