 While serving in Guangdong, Cen got into conflict with his superior, Tan Zhonglin, the Viceroy of Guangdong and Guangxi, hence he was reassigned to be a "anchashi" () in Gansu.In 1900, when the forces of the Eight-Nation Alliance attacked Beijing to suppress the Boxer Rebellion, the Guangxu Emperor and Empress Dowager Cixi fled from the capital and headed towards Xi'an.Cen led military forces from Gansu to Xi'an to protect the emperor and empress dowager, and was awarded the Imperial Yellow Jacket and earned the favour of the Empress Dowager.