Du Mu was born in the Tang capital Chang'an (modern Xi'an) into an elite family whose fortunes were declining. His grandfather was Du You, a minister at the Tang court and the compiler of the Tang Dynasty encyclopedia Tongdian. He passed the jinshi ("Presented Scholar") level of the imperial civil service examination in 828 at the age of 25, and began his career as a bureaucrat holding a series of minor posts, first as an editor of at the Institute for the Advancement of Literature. A few months later, he joined the entourage of Shen Chuanshi (沈傳師), a surveillance commissioner, first to Hongzhou, then a year later to Xuanzhou. In 833 he was sent to join Niu Sengru in Yangzhou. In Yangzhou he began to mature as a poet. In 835 he was appointed investigating censor and returned to the capital where, possibly concerned about being drawn into a factional dispute involving his friend Li Gan who had opposed Zheng Zhu, he asked to be transferred to Luoyang. This was granted, and he avoided the purge that followed the Sweet Dew Incident which happened later in the year.
Du Mu held many official positions in various locales through the years, but he never achieved a high rank, perhaps due to enemies made in a factional dispute at the imperial court in 835. In 837 he returned to Yangzhou to care for his younger brother Mu Yi who was sick and had become blind, then went to work in Xuanzhou, taking his brother with him. In 838 he was appointed Rectifier of Omission of the Left and Senior Compiler of the History Office, and he returned to Chang'an. In 840 he was promoted to Vice Director of the Catering Bureau, then transferred to the position of Vice Director of the Board of Review in 841. Starting in 842 he was made governor of a succession of small poor rural prefectures, first Huangzhou, then Chizhou and Muzhou. Du was dissatisfied with the appointment and he appeared to blame it on Li Deyu. He began to feel his career was a failure and he expressed his dissatisfaction in his poems.
In 848 Du Mu returned to Chang'an after being appointed Vice Director of Merit Titles and was awarded his old post in the History Office. He was transferred to the post of the Vice Director of the Ministry of Personnel in 849, then was appointed governor of Huzhou in 850 at his own request. He was recalled to Chang'an in 851 to the post of Director of the Bureau of Evaluation and Drafter, and was appointed to the office of Secretariat and Drafter in 852. He fell ill that winter and died before the next lunar year.