There were no immediate reports of major damage or casualties.
The US Geological Survey estimated the quake's magnitude at 5.7 and said it struck Monday evening at a depth of 10km southwest of Medan.
Susanti, a guest at a hotel in Medan, said by phone that she and dozens of other people ran outside after the quake struck.
She said, "I saw utility poles swaying. It was so scary."