He told families at a memorial service for 12 people killed by a gunman last week at the Washington Navy Yard: "There's nothing routine about this tragedy. There's nothing routine about your loss.
"Sometimes I fear there is a creeping resignation that these tragedies are just somehow the way it is. We must insist here today there is nothing normal about innocent men and women being gunned down where they work."
He was speaking at an outdoor service at Marine Barracks Washington, less than three blocks from the base where three women and nine men died in the attack.
Authorities have identified the gunman as Aaron Alexis, 34, a former US Navy reservist working as an information technology contractor. He was killed in a gun battle with police.
There were signs Alexis had untreated mental health issues.
Rhode Island police had warned the Navy in August that Alexis had reported "hearing voices" and said he believed people were following him and "sending vibrations into his body".
Mr Obama said the US military needs to do more to secure its facilities and he said the country must also make mental health treatment more available.
But he also railed against lax gun laws that he blamed for murder rates in the US. They are three times higher than in other developed nations.
"No other advanced nation endures this kind of violence. None," the president said.
"What's different in America is it's easy to get your hands on a gun."