A US drone strike that was supposed to take out members of the Daesh terrorist group in Afghanistan has instead killed at least 30 farm workers who were taking a break after a day's labor, officials say.

The attack on Wednesday night also injured 40 people as it targeted tents pitched near pine nut fields at the mountainous Wazir Tangi in eastern Nangarhar province, three officials confirmed to Reuters on Thursday.

"The workers had lit a bonfire and were sitting together when a drone targeted them," tribal elder Malik Rahat Gul told Reuters over the phone.

The owner of the fields said at least 150 workers were resting when the attack happened. Many of them remained missing, he added.

A survivor, meanwhile, said about 200 laborers were sleeping in five tents near the farm when the attack took place.

"Some of us managed to escape, some were injured but many were killed," said Juma Gul, a resident of the northeastern province of Kunar.

The attack was confirmed by Afghanistan's Defense Ministry as well as a senior US official in Kabul. However, they did not share details of civilian casualties.

"US forces conducted a drone strike against Daesh terrorists in Nangarhar," Colonel Sonny Leggett, a spokesman for US forces in Afghanistan, said. "We are aware of allegations of the death of non-combatants and are working with local officials to determine the facts."

The attack outraged local residents in Nangarhar, who urged Washington to apologize and pay compensation to the families of the victims.

A large group of local men held a protest against the attack on Thursday morning as they helped carry the victims' bodies to Jalalabad city and then to the burial site.

"Such mistakes cannot be justified. American forces must realize (they) will never win the war by killing innocent civilians," said a Jalalabad residence.

Attaullah Khogyani, a spokesman for the provincial governor, said the strike was meant to target Daesh militants who often use farmlands for training and recruitment.

About 14,000 US troops are in Afghanistan, allegedly to train and advise Afghan security forces and prepare them to take on the Talibana and Daesh.

The attack on Wednesday night preceded another deadly attack by the Taliban militant group, which killed at least 20 people in the southern Afghan province of Zabul.

Taliban have killed hundreds of civilians in clashes that followed the collapse of US-Taliban peace talks this month.

They have pledged to make US President Donald Trump regret his decision to abruptly call off talks that were on the verge of ending America's 18-year-war.

Trump ended the talks and canceled a possible meeting with Taliban leaders in the US after finding out that an American soldier was killed in a Taliban attack that killed 12 people in the capital Kabul.

According to the United Nations, nearly 4,000 civilians were killed or wounded in the first half of the year.