The manufacturer of Ashley Hernandez’s preferred baby formula for her two girls said it was out of stock on its website. Listings on eBay showed it would cost her up to $120 for a single can. So when she found a seller online offering 10 cans for $40 each, she expressed her desperation.

“I have two children,” Ms. Hernandez, 35, of Dallas, began her message. “I cannot find it. I can purchase this today. I can pay cash.”

Parents across the country are struggling to keep up with a nationwide shortage of baby formula — a problem worsened by a recent recall by Abbott Nutrition, a manufacturer of baby food. The recall came after at least four babies were hospitalized with bacterial infections and two died after consuming its products, the U.S. Food and Drug Administration said.

“We know that our recent recall caused additional stress and anxiety in an already challenging situation of a global supply shortage,” Abbott said in a statement last month. “We are working hard to help moms, dads and caregivers get the high-quality nutrition they need for their babies.”

Now, several major retailers eager to preserve inventory are limiting how much baby formula their customers can buy.

The drugstore chain CVS said in a statement that “following supplier challenges and increased customer demand,” buyers will be limited to three baby formula products per purchase in stores and online.

Walgreens echoed that in a statement, saying it had also imposed a three-item limit in an attempt “to help improve inventory.” Target said it had a four-item limit online but no in-store limits.

Costco, which did not immediately respond to an email seeking comment on Saturday, had various caps on formulas listed on its website.

“The unprecedented scope of this infant formula recall has serious consequences for babies and new parents,” Brian Dittmeier, the senior director of public policy at the National WIC Association, said on Saturday. The nonprofit provides nutritional assistance for women, infants and children across the country.

Mr. Dittmeier said that Abbott Nutrition is the exclusive supplier for more than half of the WIC agencies nationwide, meaning that “this is not an isolated issue.”

“Every day, we hear from parents who are hurt, angry, anxious and scared,” he said. “The lives of their infants are on the line.”

In retail stores, shelves are often empty. And parents online are forming Facebook groups to alert one another of restocked inventory or bargains — both rare nowadays, Ms. Hernandez said.

“It’s a nightmare,” she said.

In one Facebook group called “baby formula for sale,” a mother on Saturday begged for a specific brand: “Looking for Similac NeoSure in the Arizona area! Please help!! I’m almost out.”

Mr. Dittmeier said that “unlike other food recalls, shortages in the infant formula supply affects a major — or even exclusive — source of nutrition for babies.” Inadequate nutrition, he added, “could have long-term health implications.”

Datasembly, a retail software company, said that about 31 percent of formula products were out of stock across the country as of April. In seven states — Connecticut, Delaware, Montana, New Jersey, Rhode Island, Texas and Washington — the rate for the week of April 3 was even worse, at 40 percent.

Navigating the Baby Formula Shortage in the U.S.

Card 1 of 6

A growing problem. A nationwide shortage of baby formula — triggered in part by supply-chain issues and worsened by a recall by the baby food manufacturer Abbott Nutrition — has left parents confused and concerned. Here are some ways to manage this uncertainty:

Finding formula. If your baby’s formula was not affected by the recall, but is still not available, you can try calling local stores to ask when they expect to get it back in stock. You may also be able to buy it online. If your baby is on special formula, reach out to your doctor’s office: They might have samples in stock.

Picking a new formula. If you typically use a name-brand formula, look for its generic version. Alternatively, seek a new formula that matches the ingredients listed in your usual one. If your baby is on a special formula for health reasons, check with your pediatrician before switching.

Transitioning to a new product. Ideally, you will want to switch your child gradually. Start by mixing three quarters of your usual formula with one quarter of the new one and gradually phase out the old product. If you can’t transition gradually because you’ve run out of your usual formula, that’s OK, although you might notice more gassiness or fussiness during the transition.

What not to do. If you can’t find your baby’s usual formula, don’t make your own — homemade formulas are often nutritionally inadequate and at risk of contamination. Don’t try to “stretch” your formula by adding extra water, and don’t buy it from unvetted online marketplaces like Craigslist. For a baby less than 1 year old, don’t use toddler formula.

The shortage is also financially burdening families already grappling with a surge in inflation. The office of the U.S. Surgeon General said on its website that families typically spend up to $1,500 on infant formula in the first year.

Mr. Dittmeier said that the shortage is “particularly acute for infants who require specialty formulas to address allergies, gastrointestinal issues or metabolic disorders.”

Ms. Hernandez said that her daughters, one 6 months old and the other 3 years old, both need such specialty formula.

The seller she messaged sold her the 10 cans but that will last only about five or six weeks, she estimated. The formula she usually buys, EleCare, was one of the Abbott products recalled in February, Ms. Hernandez said.

The affected products have already been pulled from stores, but parents can use an online search through Abbott Nutrition to check the status of the products they need.

The Infant Nutrition Council of American said in a statement that formula companies were “committed to ensuring continued availability of infant formulas for every baby” during the shortage.

But Mr. Dittmeier said assurances from manufacturers about stepped-up production have not led to products reaching store shelves. “Each day that this crisis continues, parents grow more anxious and desperate to find what they need to feed their infants,” he said.