Escherichia coli (E. coli) O157:H7 can cause many food safety incidents, which seriously affect human health and economic development. Therefore, the sensitive, accurate, and rapid determination of E. coli O157:H7 is of great significance for preventing the outbreak and spread of foodborne diseases. In this study, a carbon dots-Fe3O4 nanomaterial (CDs-Fe3O4)-based sensitive electrochemical biosensor for E. coli O157:H7 detection was developed. The CDs have good electrical conductivity, and the surface of carbon dots contains abundant carboxyl groups, which can be used to immobilize probe DNA. Meanwhile, the CDs can be used as a reducing agent to prepare CDs-Fe3O4 nanomaterial. The Fe3O4 nanomaterial can improve the performance of the electrochemical biosensor; it also can realize the recovery of CDs-Fe3O4 due to its magnetism. As expected, the electrochemical biosensor has excellent specificity of E. coli O157:H7 among other bacteria. The electrochemical biosensor also exhibited good performance for detecting E. coli O157:H7 with the detection range of 10–108 CFU/ml, and the detection limit of this electrochemical biosensor was 6.88 CFU/ml (3S/N). Furthermore, this electrochemical biosensor was successfully used for monitoring E. coli O157:H7 in milk and water samples, indicating that this electrochemical biosensor has good application prospect. More importantly, this research can provide a new idea for the detection of other bacteria and viruses.