The commuter train was heading from a town in western Dagestan , Khasavyurt , to the regional capital , Makhachkala , early Sunday when the explosion occurred .