Nonspecific adsorption of biomolecules (notably, proteins) and bacteria from unsterilized food may occur on sensor surfaces, which is still a challenge for food safety sensing. To achieve sensitive detection of unsterilized raw-food materials, in this study, a U-shaped four-in-one peptide with the sequence Ac-FLKLLKKLL-DOPA3-PPPPEEKDQDKEKaa that exhibited anchoring, antifouling, antibacterial, and recognition properties was designed. The peptide-modified sensor surface effectively prevented bacterial adhesion and proliferation while resisting biomolecule adsorption (signal inhibition rate as low as 0.51 % in single-protein solutions). A highly conductive polymer layer of poly(3,4-ethylenedioxythiophene) was introduced to improve the electrochemical performance before U-shaped four-in-one peptide anchoring. The proposed sensor could accurately detect vancomycin, with a wide linear range and limit of detection of 0.05–10 μg mL−1 and 2.06 ng mL−1 (S/N = 3), respectively. Satisfactory recovery rates (101.3–105.3 %) were achieved using diluted fresh goat milk.