Objective Acute lung injury (ALI) is one of the common and severe complications of cardiopulmonary bypass (CPB), which is the primary cause of death in intensive care units. Nevertheless, there is a lack of effective treatment for ALI secondary to CPB. κ -Opioid receptor (KOR) agonists have been demonstrated to improve lung function after pulmonary hypertension. However, its protective role has been barely reported in CPB-induced acute respiratory distress syndrome (ARDS). Therefore, this research focused on the protective effect of a KOR agonist U50448H on ARDS and investigated its potential relationship with the NOD-like receptor family pyrin domain-containing 3 (NLRP3) inflammasome. Method Forty-five rats were randomly allocated into Sham, CPB, and U50448 groups ( n = 15 rats/group). After a CPB model was successfully established in rats, CPB rats were treated with the KOR agonist U50448H. The values of extravascular lung water (EVLW), alveolar-arterial oxygen tension difference (AaDO2), and respiratory index (RI) were examined, and the lung wet/dry ( W / D ) weight ratio was also calculated. Western blot (WB) was utilized to measure the expression of MMP-9, GSDMD-C, GSDMD-N, NLRP3, ASC, pro-Caspase-1, pro-IL-1 β , and α 7-nAChR. The immunofluorescence assay was performed for examining the expression of ROS, F480, iNOS, CD206, and α 7-nAChR. Cell apoptosis was detected by the TUNEL assay. ELISA was used to test the level of LPS in serum and the level of MDA, GSH, SOD, TNF- α , IL-4, IL-6, IL-18, and IL-1 β in lung tissues. Results It was observed that the administration of U50448H significantly reduced EVLW values and LPS levels in the lung of rats. Meanwhile, U50448H increased AaDO2 values while decreasing RI values. Moreover, the administration of U50448H alleviated the pathological damage caused by ALI secondary to CPB. U50448H repressed ROS release and oxidative stress responses, as well as lowered LPS levels in plasma and MMP-9 expression in the lung of CPB rats. Furthermore, U50448H facilitated the shift of macrophage phenotype to M 2. In addition, U50448H decreased the activity of the CAP-NLRP3 inflammasome and suppressed pyroptosis in pulmonary cells. Conclusion The KOR agonist U50448H improved lung function and relieved lung injury in CPB rats, accompanied by diminished ROS and MMP-9 levels in lung tissues, promoted macrophage polarization from M 1 to M 2, and reduced NLRP3 inflammasome activities. These results indicated U50448H as a promising drug for the treatment of ALI secondary to CPB.