There were no reports of damage and a tsunami warning was not issued.
The US Geological Survey said the quake hit at a depth of nine kilometres, just over 300 kilometres west of the coastal city Banda Aceh.
It occurred at around 7:00am, USGS said.
“The quake was felt strongly for a few seconds by residents on the west coast,” said national disaster agency spokesman Sutopo Purwo Nugroho. “Some people ran out of their homes.”
Mochammad Riyadi, from the Indonesian meteorology, climatology and geophysics agency, said there were no reports of casualties or damages.
“The magnitude may be big but the epicentre is at sea and relatively far away from the nearest city, Banda Aceh,” he said.
Banda Aceh was devastated by a huge tsunami in 2004, which killed some 170,000 people in the surrounding region, as well as tens of thousands more in countries around the Indian Ocean.
Indonesia sits on the Pacific “Ring of Fire” where continental plates collide, causing frequent seismic and volcanic activity.