Objective To investigate the immune function and risk factors in opioid addicts during rehabilitation. Methods The study was conducted in compulsory isolated detoxification center of Shanghai in 2010.10-2011.7. The opioid addicts who had been abstained from opioid for 15 d were enrolled as subjects. There was no pharmacotherapeutic treatment of drug addiction during the 24 week of study. The immune function indices and risk factors were analyzed. Results At the beginning of rehabilitation, lower CD3+ T cell levels, as well as higher serum IL-2, IFN-γ, TNF-α, IL-4, IL-6 and IL-10 production were observed compared with the healthy subjects. Opioid withdrawal skewed T cells towards Th2 polarization. During rehabilitation, IgG value was likely to elevate while IgM value reduced without beyond the normal range. The number of CD3+T cell in opioid addict had a trend of increase, and showed no significant difference compared to the healthy ones at the 24th week. All the serum cytokines and cortisol expressed as decrease to suppression during 24 week. Besides, Th1/Th2 recovered at the 4th week, but the level of COR significantly decreased to below normal.. The changes were related to method, duration of drug use, and times of relapse. HAMA was the risk factor for abnormal IFN-γ and TNF-α (OR were 1.26 and 1.11, respectively), while protracted withdrawal symptoms scores was the risk factor for abnormal IL-2 and IL-10 (OR were 1.12 and 1.19, respectively). Conclusion The immune fuction in opioid addicts remained abnormal during initial rehabilitation. They were improved within 24 w of rehabilitation. However, the serum cytokines and cortisol decrease to suppression since the 4th to 12th week, which suggests that the recovery of immune function take a long time.