Bimetallic oxide nanocomposites have emerged as promising electrochemical sensors with low detection limits and high sensitivity. In this study, erbium oxide/cobalt oxide (Er2O3/Co3O4) nanocomposites were successfully prepared using a hydrothermal method for the electrochemical sensing of 4-nitroaniline (4-NA). The structure, morphology, and composition of the prepared nanocomposites were characterized using various techniques. The nanocomposites were coated onto a glassy carbon electrode, and their electrochemical properties were investigated via cyclic voltammetry and differential pulse voltammetry in a 0.1 M phosphate buffer solution over a potential range from -1.1 to 0.4 V. The electrode featured a large electrochemical active surface area, excellent conductivity, and a synergistic effect, all of which contributed to its outstanding performance in detecting 4-NA. Among nanocomposites with varying erbium concentrations (5, 10, 15, and 20%), 15% Er2O3/Co3O4 showed the best electrochemical behavior. The resulting sensor demonstrated a wide linear range (0.040-2500 mu M), a low detection limit of 0.022 mu M, and excellent sensitivity. In addition, the sensor exhibited excellent reproducibility and repeatability. Moreover, the 15% Er2O3/Co3O4-based sensor was successfully applied for the real-time detection of 4-NA in river, well, and pond water samples, achieving satisfactory recovery rates. These findings demonstrated the efficiency and reliability of the constructed sensor for detecting 4-NA, highlighting its potential for practical environmental monitoring.