Our study determined the risk factors to stop using IV PCA due to side effects following lung or esophageal surgery. These results emphasize the need for personalized pain management plans that take into account the patient's characteristics and the type of surgery performed.