BECKLEY, W.Va. – At a somber memorial for 29 coal miners Sunday, President Obama said it is a moral imperative for the United States to prevent the sort of underground explosion that triggered the worst mine disaster in four decades.

The president said he has been flooded with messages since the April 5 tragedy at West Virginia’s Upper Big Branch mine, with people imploring him: “Don’t let this happen again.”

“How can we fail them?” Obama told about 2,800 mourners at the Beckley-Raleigh County Convention Center. “How can a nation that relies on its miners not do everything in its power to protect them? How can we let anyone in this country put their lives at risk by simply showing up to work, by simply pursuing the American dream?”

He added: “Our task, here on Earth, is to save lives from being lost in another such tragedy. To do what we must do, individually and collectively, to assure safe conditions underground. To treat our miners like they treat each other, like a family. Because we are all family and we are all Americans.”

Obama’s eulogy came toward the end of a service that was an emotional testament to the human toll of unsafe mining conditions. The cause of the blast that killed the miners is still under investigation, but high levels of methane are suspected. The explosive gas had to be vented from the mine and neutralized with nitrogen to allow rescue and recovery teams to enter.

Sitting in the audience was Don L. Blankenship, head of Massey Energy Co., which owns the Upper Big Branch mine. The White House said the president did not speak with him Sunday but did meet privately with family members of the victims.

Massey has been cited repeatedly over the mine. In 2009 alone, the Mine Safety and Health Administration issued 48 orders that workers be removed from parts of the mine for “repeated significant and substantial violations” constituting a hazard.

Two weeks ago, after Obama received a scathing report about the mine, he described Massey as a safety violator that should be held accountable. The report said the mine’s rate for such violations is nearly 19 times the national rate.

Massey, the nation’s sixth-largest coal-mining firm, says it has a better-than-average safety record and has received safety awards during Obama’s tenure.