Cocaine is a white crystalline alkaloid extracted from coca leaf. It can block human nerve conduction, produce local anesthetic effect, and has strong addiction. Therefore, the qualitative and quantitative analysis of cocaine is of great significance in forensic toxicology, pharmacy and metabolomics. Cocaine aptamer probe is expected to become a powerful tool for on-site detection of cocaine due to its good stability, fast response speed, and easy preparation of kits for on-site application. In our work, we construct a fluorescent biosensor for the detection of cocaine by using the characteristics of specific binding of nucleic acid aptamers to targets and combining with enzyme-free nucleic acid signal amplification reaction. First, streptavidin-modified magnetic beads (MBs) can specifically bind to biotin-modified cocaine aptamer probe (Aptamer) to form MB-DNA. The nucleic acid aptamer complementary probe (tDNA) can hybridize with the aptamer through base complementary pairing to form a double strand, thereby obtaining the MB-DNA-tDNA complex. When cocaine is present in the system, cocaine specifically binds to aptamer, thereby replacing the probe tDNA. The probe tDNA can undergo hybridization chain reaction with the hairpin probe 1 (HP1) and hairpin probe 2 (HP2), resulting in the opening of the hairpin structure, and the fluorescence signal response of the fluorophore 6-carboxyfluorescein (FAM) modified on the HP1 is turned on, so as to achieve rapid, low-cost and efficient cocaine detection. The establishment of this method can enrich and develop the basic theory of drug analysis and detection, and provide theoretical guidance and technical support for the accurate, efficient and convenient detection of drug analysis methods on site.