Health officials are warning consumers to avoid prepackaged caramel apples because they are linked to four deaths and more than two dozen illnesses in 10 states, including Minnesota, where two people died.

Caramel apples are most popular around Halloween, and the outbreak started just before then, in mid-October. But the commercially produced variety can have a shelf life of a month or more, and some may still be on store shelves.

The Centers for Disease Control and Prevention said it knows of 28 cases in which people were sickened with the same strains of the bacterial illness listeria, and at least 26 were hospitalized. Of those, five died. Listeriosis contributed to four of the deaths; a fifth person who died had a strain of listeria linked to the caramel apples, but health officials do not think listeriosis caused that person’s death.

The agency said that 83 percent of the ill people who were interviewed reported eating commercially produced, prepackaged caramel apples before getting sick.

The CDC said the investigation into the deaths and illnesses is “rapidly evolving.” Christopher Braden, an epidemiologist at the CDC, said the agency is still trying to determine which brands are involved and how caramel apples may have become infected. He said there is no reason at this point to stop eating plain apples or other caramel products.

Two of the deaths were in Minnesota, and health officials in that state said those who fell ill there purchased the caramel apples from the stores Cub Foods, Kwik Trip, and Mike’s Discount Foods. Those stores carried Carnival brand and Kitchen Cravings brand caramel apples, none of which are still available for purchase, according to the Minnesota Department of Health. They said other brands and store locations may be impacted as the investigation continues.

The CDC said the other two deaths were in Texas and California. The agency said illnesses also occurred in Arizona, California, Missouri, New Mexico, North Carolina, Texas, Utah, Washington, and Wisconsin. Missouri and New Mexico had the most illnesses, with five each.

It was unclear if listeriosis was the primary cause of the Texan’s death, said Christine Mann, spokeswoman for the Texas Department of State Health Services.

Listeria is a foodborne illness that is especially dangerous to pregnant women, newborn babies, the elderly and those with compromised immune systems. It rarely causes serious illness in healthy people and can be treated with antibiotics. Symptoms include fever, muscle aches, nausea and diarrhea.

Because it can be so serious for some people, outbreaks of listeria generally cause more deaths than other pathogens such as salmonella or E. coli. An outbreak of listeria linked to Colorado cantaloupe in 2011 caused 33 deaths.

The CDC said that the outbreak linked to the caramel apples began Oct. 17 and the last known illnesses started Nov. 27. The agency said illnesses that have occurred since early December may not have been reported yet. Those sickened have included infants and older children and others as old as 92.

Nine of the illnesses involved either a pregnant woman or an infant, the CDC said. Listeria is dangerous for pregnant women because the illness can be passed to an unborn baby even if the mother is not showing signs of illness. It can sicken a newborn or lead to miscarriage, preterm delivery or stillbirth. The CDC said no miscarriages or fetal losses were reported in this outbreak.

Unusually, three cases of meningitis linked to the listeria were reported in older children, the agency said. Those three children were not among the deaths, Braden said, but the CDC is “very concerned” that those cases occurred in otherwise healthy children. While listeria can infect newborns, “usually we would not see this kind of infection in healthy older children,” Braden said.

Braden said there may have been more illnesses in children because kids are more likely to eat caramel apples, or possibly because the apples were heavily contaminated.

He said anyone with commercially produced, prepackaged caramel apples at home should throw them away, taking care to wrap them up well so animals or people going through trash don’t eat them.