Detecting ovarian cancer at an early stage is crucial for enhancing patient outcomes, underscoring the demand for an efficient and non-invasive detection method. Cancer antigen 125 (CA125) is a vital biomarker in ovarian cancer detection, and there is a pressing demand to develop a quick, sensitive, and simple detection method. Nanobiosensors are increasingly being used by scientists due to their high selectivity and sensitivity, allowing for the swift and precise detection of a wide range of biomarkers. This study aimed to design and fabricate an electrochemical nanobiosensor that could accurately and selectively detect CA125. The nanobiosensor employed graphitic carbon nitrides, molybdenum disulfide, and polyaniline (g-C3N4/MoS2/PANI) to stabilize aptamer strands on a modified glassy carbon electrode. The aptasensor was used to perform electrochemical detection of labeled CA125, utilizing methylene blue and label-free ferrocyanide methods. Ferrocyanide and methylene blue detection limits were determined to be 0.196 U.mL−1 for ferrocyanide and 0.196 U.mL−1 for methylene blue, with a linear detection range of 2–10 U.mL−1 for linear detection. The study results showed that the modified electrode exhibited high selectivity towards CA125 and superior stability compared to other biomolecules. The electrochemical aptasensor also displayed impressive performance when analyzing the serum of patients and healthy people. These findings hold significant promise for future investigation in ovarian cancer diagnosis. This novel electrochemical nanobiosensor may aid in the early detection and management of ovarian cancer, ultimately leading to better patient outcomes.