In this study, cooling of a hot obstacle in a rectangular cavity filled with water-CuO nanolfuid has been examined numerically. This cavity has an inlet and outlet and the cold nanofuid comes from the left side of the cavity and after cooling the hot obstacle, it goes out from the opposite site. All of the walls are insulated, and the SIMPLER algorithm has been employed for solving the governing equations. The effects of fluid inertia, magnetic field strength, volume fraction of nanoparticles, and the place of outlet on heat transfer rate has been scrutinized. According to the results, the average Nusselt number builds up as the outlet place goes down. In other words, when the outlet is located at the bottom of the cavity, the rate of the heat transfer is maximum. Moreover, by increasing the Reynolds number and volume fraction of nanoparticles, the average Nusselt number builds up as well.