The risk factors of urinary tract infection in elderly patients with type 2 diabetes were investigated. A total of 72 elderly patients admitted to our hospital from December 2019 to September 2023 because of with type 2 diabetes were retrospectively included. They were divided into the observation group (n = 35) and control group (n = 37) according to whether they had urinary tract infection. The general clinical data, clinical characteristics and the distribution of pathogenic bacteria in the observation group were collected and analysed. Then, t-tests, chi-square tests, regression analysis and receiver operating characteristic curve analysis were conducted. Escherichia coli (E. coli) accounted for 51.43% of the pathogenic bacteria in the observation group, whereas Klebsiella pneumoniae (K. pneumoniae) accounted for 22.86%. The remaining pathogens accounted for 2.86% each. Differences in gender, course of disease, glycosylated haemoglobin and comorbid urinary calculi were found between the groups (p < 0.05); These factors were all risk factors for concurrent urinary infection, and the odds ratios were all >1. The obtained values for gender, disease course, glycosylated haemoglobin and comorbid urinary calculi were respectively 0.594, 0.654, 0.738 and 0.696 (area under the curve); 0.971, 0.714, 0.800 and 0.743 (sensitivity); 0.216, 0.595, 0.676 and 0.649 (specificity); And 0.188, 0.309, 0.476 and 0.392 (Youden index). Common pathogens in elderly people with type 2 diabetes and comorbid urinary tract infection are E. coli and K. pneumoniae. Risk factors include gender, disease duration, glycosylated haemoglobin and urinary stones. The prompt identification of pathogens and risk factors facilitates clinical treatment, reducing infection incidence.