In this paper, a nonlinear stochastic eco-epidemic model is presented to study the dynamics of harvested prey–predator model with group defence. One of the key roles of forming a group is to defend themselves from the attack of the predators. Since prey population spreads infection through direct contact; we consider two groups of prey population. Using some certain assumptions, a stochastic model is formulated by considering noisy intrinsic growth rate of susceptible pest population, death rate of infected pest and predator populations, respectively. Next, the existence and uniqueness of positive solution are performed using comparison theorem of stochastic differential equations (SDEs). The boundedness and uniform continuity of the system are analyzed. Then, the bionomic equilibrium and optimal harvesting policy are obtained by using stochastic maximum principle. We verify the conditions of extinction and persistence in mean with the numerical results. To verify our consideration with the reality, the effects of harvesting effort and catchability coefficient are observed. In addition, infected and uninfected regions are reported to specify the infection free system.