Choledochoscopy is a highly effective approach for managing intrahepatic bile duct stones (IHDs). However, postoperative infection is a common complication that significantly impacts treatment outcomes. Despite its clinical relevance, the risk factors associated with this procedure remain largely unexplored. This study focused on a consecutive cohort of patients who underwent choledochoscopy for IHDs at our institution between January 2016 and December 2022. The primary objective was to analyze the relationship between various clinical factors and postoperative infection, and to compare the postoperative infection of different choledochoscopic procedures. The study cohort consisted of 126 patients, with 60 individuals (47.6%) experiencing postoperative infection. Notably, preoperative biliary obstruction (odds ratio [OR] 1.861; 95% confidence interval [CI] 1.314-8.699; p = 0.010) and operation time (OR 4.414; 95% CI 1.635-12.376; p = 0.004) were identified as risk factors for postoperative infection. Additionally, biliary tract infections (60.00%) were primarily responsible for postoperative infection, with Escherichia coli (47.22%) being the predominant bacterial strain identified in bile cultures. Furthermore, biliary tract obstruction (OR 4.563; 95% CI 1.554-13.401; p = 0.006) and body mass index (BMI) (OR 1.186; 95% CI 1.015-1.386; p = 0.031) were determined to be independent risk factors for postoperative biliary tract infection. The occurrence of postoperative infection in patients undergoing choledochoscopy was primarily associated with the duration of the operation and the presence of preoperative biliary obstruction.