SummaryCloud data centers (CDCs) have revolutionized global computing by offering extensive storage and processing capabilities. Nevertheless, the environmental impact of these processes, including their substantial energy consumption and carbon emissions, calls for implementing more efficient techniques. Efficient virtual machine (VM) consolidation is crucial in optimizing resource utilization and reducing energy consumption. Current methods for enhancing energy efficiency often lead to issues such as service level agreements (SLAs) violations and quality of services (QoS) degradation. This study presents a novel approach to host selection using a grey‐extreme (GE) machine learning model, which accurately predicts over and underutilized hosts. In addition, a VM placement technique called enhanced black widow optimization (EBWO) utilizes black widow optimization heuristic techniques and a differential evolutionary approach to optimize VM placement. The proposed dynamic VM consolidation technique optimizes energy utilization while meeting strict SLA requirements and enhancing QoS metrics in CDCs. Extensive analyses were conducted using the Cloudsim toolkit to validate the approach's effectiveness. These analyses encompassed conditions such as random workloads in heterogeneous environments. The simulation results showed that GE‐EBWO outperforms other techniques and improves energy efficiency by 12%–15%. In addition, it significantly decreases VM migrations by 11%–14% compared to other advanced methods. The study validates the practicality of the proposed technique in moving towards environmentally friendly CDCs.