We present a comprehensive analysis in the 3+1 active-sterile neutrino oscillation scenario for the sensitivity of the ESSnuSB experiment in the presence of light sterile neutrinos assuming both a far (FD) and a near (ND) detector. Our analysis show that when the ND is included, the results are significantly different compared to the ones obtained with the FD only. We find that the capability of ESSnuSB to constrain the sterile mixing parameters is sin 2 2θ µe ∼ 10 −4 for ∆m 2 = 1 eV 2 if the ND is included and it becomes sin 2 2θ µe ∼ 10 −2 without the ND. Furthermore, we show that the sensitivity can go down to sin 2 2θ µe ∼ 10 −3 for the most conservative choice of the systematics on the ND. Comparing the sensitivity with T2HK, T2HKK, and DUNE by considering the FD only, we find that the sensitivity of ESSnuSB is smaller for most of the parameter space. Studying the CP violation sensitivity, we find that if the ND is included, it can be larger in the 3+1 scenario than in the standard one. However, if the ND is not included, the sensitivity is smaller compared to the one in the standard scenario. We also find that the CP violation sensitivity due to δ 13 is larger compared to the one induced by δ 24 . The sensitivities are slightly better for the dominant neutrino running ratio of ESSnuSB.