Six years later, at the age of 28, Cui Yan befriended Gongsun Fang () and others and they studied together under the tutelage of the Confucian scholar Zheng Xuan. However, in 194, before Cui Yan could even complete his first year of studies, the Yellow Turban rebels from Xu Province attacked Beihai Commandery, where Zheng Xuan conducted his classes, so Zheng and his students fled east to Mount Buqi (不其山; northwest of Mount Lao) to evade chaos. Despite so, the rebellion had resulted in food shortages, so Zheng Xuan had no choice but to send his students away. After leaving Mount Buqi, Cui Yan could not return to Qinghe Commandery because rebel forces and bandits were rampant in the region and the roads leading west were blocked. He wandered around Qing, Xu, Yan and Yu provinces and visited several places, including Shouchun (壽春; present-day Shou County, Anhui), Lake Tai and the northern bank of the Yangtze River. After four years, he returned home and spent his time playing music and writing calligraphy.