WINCHESTER, Ill. — John Paul Coonrod had a banana problem.

The only grocery store in his 1,500-person hometown in central Illinois had shut its doors, and Mr. Coonrod, a local lawyer, was racing to get a community-run market off the ground. He had found space in an old shoe store, raised $85,000 from neighbors and even secured a liquor license to sell craft beer. But then his main produce supplier fell through.

The stakes of failure were huge. Farm towns like Winchester that produce beef, corn and greens to feed the world are becoming America’s unlikeliest food deserts as traditional grocery stores are forced out of business by fewer shoppers and competition from dollar-store chains. Their exodus has left rural towns worried about how they can hold on to families, businesses and their future if there is nowhere to buy even a banana.

“It’s the story of every small town,” Mr. Coonrod, 35, said. “It’s a domino effect, and it starts with the grocery store.”