In the current century, electrical networks have witnessed great developments and continuous increases in the demand for fossil fuels based energy, leading to an excessive rise in the total production cost (TPC), as well as the pollutant (toxic) gases emitted by thermal plants. Under this circumstances, energy supply from different resources became necessary, such as renewable energy sources (RES) as an alternative solution. This latter, however, characterized with uncertainty nature in its operation principle, especially when operator system wants to define the optimal contribution of each resource in an effort to ensure economic and enhanced reliability of grid. This paper presents an Enhanced version of Kepler optimization algorithm (EKOA) to solve the problem of stochastic optimal power flow (SOPF) in a most efficient way incorporating wind power generators and solar photovoltaic with different objective functions, the stochastic nature of wind speed and solar is modeled using Weibull and lognormal probability density functions respectively. To prove the effectiveness of the proposed EKOA, various case studies were carried out on two test systems IEEE 30-bus system and Algerian power system 114-bus, obtained results were evaluated in comparison with those obtained using the original KOA and other methods published in the literatures. Thus, shows the effectiveness and superiority of the efficient EKOA over other optimizers to solve complex problem. The incorporation of RES resulted in a significant 2.39% decrease in production cost, showcasing EKOA’s efficiency with a $780/h, compared to KOA’s $781/h, for IEEE 30-bus system. For the DZA 114-bus system revealed even more substantial reductions, with EKOA achieving an impressive 12.6% reduction, and KOA following closely with a 12.4% decrease in production cost.