The significance of heat transfer and nanofluid flow in cavities with local heaters is investigated in the present study, crucial in numerous applications in engineering. The research focuses on the magnetohydrodynamic (MHD) with natural convection f low of Cu-water nanofluid inside a square cavity that includes a centrally positioned adiabatic block in square form. The enclosure features heated sections located proximate to all the corners (referred to as heated corners) with both the left and right wall sections being cooled. On the top and bottom walls, the remaining segments are adiabatic. This configuration sets the stage for exploring heat transfer dynamics and fluid behavior within the porous medium, offering insights into the thermal interactions within the cavity. The mathematical formulation of the problem is detailed in the subsequent section. Notably, it is clear that as heat source lengths increase, the local Nu number does as well (B) in all cases. The overall entropy generation is observed to diminish with a rise in the fraction of nanoparticle volume and the Rayleigh number. As the Hartmann number’s volume fraction rises, the average Nusselt number falls. Although the percentage of growth is higher for the rate of thermal performance, increasing the Darcy numbers improves the nanoparticle volume fraction. By raising the volume percentage of the nanoparticles, the total entropy creation is rising. The average Nu number falls with rising magnetic field strength