© 2021, The Author(s), under exclusive licence to Springer-Verlag GmbH Germany, part of Springer Nature.Increasing rates of extended-spectrum beta-lactamase (ESBL) producing E. coli and K. pneumoniae over time made empirical treatment complicated. Knowing local antimicrobial resistance patterns of common pathogens can make it easier to decide on empirical antibiotics. We aimed to investigate the prevalence and risk factors of ESBL positivity of E. coli and K. pneumoniae strains in uncomplicated and complicated pyelonephritis acquired in community and healthcare associations and to evaluate the appropriateness of empirical treatment. Adult patients hospitalized with diagnosis of community-acquired or healthcare-associated uncomplicated/complicated pyelonephritis initiated empirical antimicrobial therapy were included in the study. Appropriateness of empirical treatment at 48–72 h based on culture results and treatment modifications were evaluated. A total of 369 uncomplicated (94) and complicated (275) episodes of pyelonephritis were evaluated. The most common agents were E. coli (71.0%) and K. pneumoniae (17.7%), and the ESBL-production rate was 64.4%, and higher in healthcare-associated pyelonephritis (P 0.013). Being of healthcare-associated infection, previous antibiotic use, and presence of urinary catheters were independent risk factors for ESBL-producing E. coli and K. pneumoniae (P 0.009, < 0.001, and 0.024, respectively). The treatment inappropriateness was mostly associated with use of ceftriaxone (56.3%) (P < 0.001). Treatment has escalated in 41.5% of ceftriaxone-initiated patients, in only 8.8% and 9.5% ertapenem and piperacillin-tazobactam-initiated patients, respectively. ESBL-production rates are quite high even in community-acquired infections. The use of broad-spectrum antibiotics covering ESBL-producing pathogens to increase the appropriateness of empirical treatment and then narrowing treatment based on culture results appears a better and life-saving choice.