| To explore the risk factors of nosocomial infection in patients with hepatitis B cirrhosis and upper gastrointestinal bleeding by multivariate regression analysis, and to provide references for clinical prevention and control. Methods The clinical data of 317 hepatitis B cirrhosis patients with upper gastrointestinal bleeding, who were hospitalized in our hospital from June 2015 to may 2018, were retrospectively analyzed. The patients were divided into infection group and non-infection group according to whether hospital infection occurred. The distribution and location of pathogenic bacteria were examined, and the risk factors of nosocomial infection were analyzed by single factor analysis and logistic regression model. Results Among the 317 patients, 75 had nosocomial infection with an infection rate 23.66%. A total of 34 pathogenic organisms was detected, including 18 gram-negative bacteria (52.94%), 11 gram-positive bacteria (32.35%) and 5 fungi (14.71%). The three most commonly infected areas were abdominal cavity, upper respiratory tract and lower respiratory tract. Single factor analysis revealed that there were statistically significant differences in hemoglobin level, serum protein level, HBV-DNA level, prophylactic use of antibiotics, usage of compression hemostasis with three lumens and two bladders and usage of endoscopic ligation hemostasis between infected and uninfected patients (P<0.05). Logistic analysis showed that the risk factors of nosocomial infection in patients with hepatitis B cirrhosis and upper gastrointestinal bleeding were age≥50 years old, hemoblobin<7 g/L, serum protein<28 g/L, HBV-DNA≥500 cps/mL, non-prophylactic use of antibiotics, non-use of compression hemostasis with three lumens and two bladders, and non-use of endoscopic ligation hemostasis. Conclusion The nosocomial infection rate of patients with hepatitis B cirrhosis and upper gastrointestinal bleeding is high. Taking effective measures to deal with the risk factors is helpful to control and reduce the infection.