The government established the towns during the Huangshi and Yanhe eras to prevent the southward invasion by the Rouran Khaganate.
This rebellion was rooted in the internal struggle within the Six Garrisons between upper-class military elites and lower-class soldiers and ethnic settlers and was directly triggered by a serious drought causing a massive loss of livestock and leading to the looting of Avars.
Six Garrisons were established to protect the Northern Wei regime from the invasion of Rouran and consisted of numerous ethnic groups, such as Xianbei, Han, Gaoche, and Xiongnu.
The internal conflict between upper-class military elites and lower-class soldiers and ethnic settlers was on the basis of the vulnerable economic base (heavily relied on livestock production and the support from the central government) and harsh environmental conditions in Six Garrison areas.
The struggle for survival drove military officers of Six Garrisons to implement unfair policies biased to their own ethnic groups at the cost of others.
Elsewhere in Qinzhou (modern Gansu province), Qiang leaders such as Mozhe Dati (莫折大提) also rose up.