Codeine is among naturally occurring alkaloids in opioid plants, has long been used as a drug, and is also abused. Thus, developing a selective, specific and straightforward method to detect codeine is highly demanded in various fields. In this work, we have fabricated a novel electrochemical biosensor based on covalent immobilization of a DNA aptamer onto the multiwalled carbon nanotubes/chitosan nanocomposite (MWCNT/Chit) for electrochemical determination of Codeine. The applied redox mediator has been wired on the electrode surface. Upon codeine addition, a complex was formed between the DNA aptamer and codeine which led to decrease in the current of wired electrochemical redox indicator. The decrease in current was linear with codeine concentration. Furthermore, the proposed aptasensor was able to selectively detect codeine in the presence of different interfering compounds. Finally, this aptasensor was successfully used to detect codeine in real samples.