ABSTRACT Security is the primary concern when creating security protocols for wireless sensor networks (WSN), which motivates many academics to find security solutions that effectively provide a few benefits, such as low consumption of electricity, flexible communication, and low cost. A few restrictions still remain, including the inability to exactly select the expected cluster, the sensor nodes’ constrained functionality, and their poor efficiency. Thus, Egret-Harris optimization for hybrid secure routing and monitoring mechanisms in IoT-based WSNs (EHO optimized routing protocol in WSN) was introduced in this research. The created EHO algorithm combines the search, fitness function, and hunting phase features from Harris hawks and egrets to determine the best solution among all practical solutions while ensuring safe data transfer from the cluster heads (CHs) to the Base station (BS). Specifically, the EHO-enabled clustering is applied to the suggested model to efficiently choose the ideal group of CHs. Additionally, the EHO algorithm assists in choosing the best possible routes with minimal distance and less delay for facilitating energy-efficient transmission. With 100 nodes analyzed, the suggested EHO-WSN approach without any attacks achieved 22 alive nodes, a delay of 0.10 ms, a normalized energy of 0.346J, and a throughput of 0.64 bps, respectively. Additionally, in the presence of a Sybil attack, the suggested EHO-WSN technique achieves 14, 0.214 J, 0.010 ms, and 0.512 bps for an analysis involving 100 nodes. Compared to previous methods, the suggested EHO-WSN model without attack achieves a delay of 0.07 ms, a throughput of 0.30 bps, an energy of 0.374 J, and 37 alive nodes for 200 node evaluation. For 200 nodes under examination, the EHO-WSN technique yields superior results of attaining 12 alive nodes, a delay of 0.072 ms, a throughput of 0.181 bps, and a normalized energy of 0.330 J even in the presence of the Sybil attack and exceeded other traditional techniques.