How Can You Get a Urinary Tract Infection?

Urinary tract infections happen when bacteria enter the urethra and travel up into the bladder. About 80% of UTIs are caused by E. coli, a bacterium that normally lives in the gut but causes problems when it reaches the urinary tract. Understanding the specific ways bacteria make that journey can help you reduce your risk.

The Basic Mechanism

Bacteria that live harmlessly in the intestines gradually migrate to the skin around the urethra. From there, they colonize the urethra itself, then move upward into the bladder, where they can form resistant communities on the bladder wall. Once established, these bacteria trigger the inflammation, burning, and urgency that characterize a UTI.

Women get UTIs far more often than men, and the reason is largely anatomical. The average adult female urethra is only about 3 centimeters long, giving bacteria a much shorter path to the bladder. Men have a significantly longer urethra, which acts as a natural barrier against ascending infection.

Sexual Activity

Sex is one of the most common triggers for UTIs in women, sometimes called “honeymoon cystitis.” During intercourse, bacteria from the genital and anal area can be physically pushed toward and into the urethra. Inadequate lubrication makes this worse. When vaginal tissues are dry, there’s more friction and mechanical irritation to the urethra, and the tissue surrounding it doesn’t engorge the way it normally would to help seal the urethral opening.

Certain sexual practices raise the risk further. Moving from anal to vaginal contact without washing introduces fecal bacteria directly to the vaginal area, giving E. coli a short path to the urethra. Urinating shortly after sex helps flush bacteria that may have entered the urethra before they can travel to the bladder.

Contraceptive Methods

Spermicides are a well-established risk factor. Products containing nonoxynol-9, whether applied directly or coating a condom, disrupt the normal bacterial balance in the vagina. Healthy vaginal bacteria help keep infection-causing organisms in check, and spermicides suppress them. Research has found that young women using spermicide-coated condoms had roughly three times the risk of developing a UTI compared to sexually active women who didn’t use them. Diaphragms carry a similar risk, both because they’re typically used with spermicide and because the device itself can press against the urethra, making it harder to fully empty the bladder.

Hormonal Changes After Menopause

Estrogen plays a surprisingly large role in urinary tract defense. It keeps the tissues of the vagina and urethra elastic and moist, and it supports the population of protective bacteria that live in those areas. These healthy bacteria compete with and crowd out organisms like E. coli.

After menopause, falling estrogen levels thin the vaginal and urethral tissues, cause dryness, and weaken the urethral muscles. At the same time, the population of protective bacteria drops. The combined effect is a urinary tract that’s more vulnerable to colonization. This is why recurrent UTIs become increasingly common in postmenopausal women, even those who had few or no infections earlier in life.

Not Fully Emptying the Bladder

Urine that sits in the bladder becomes a breeding ground for bacteria. Anything that prevents you from emptying your bladder completely raises your infection risk. An enlarged prostate is the most common cause in men: the prostate presses against the urethra and blocks the normal flow of urine. Nerve damage from conditions like multiple sclerosis, spinal cord injuries, or diabetes can also interfere with the signals between the brain and bladder, leading to incomplete emptying. Even habitually “holding it” for long periods gives bacteria more time to multiply.

Diabetes and Immune Function

People with diabetes face a higher UTI risk through multiple pathways. High blood sugar weakens the innate immune system, the body’s first line of defense against infection. Research from Karolinska Institutet found that high glucose levels reduce the production of a natural antimicrobial substance called psoriasin in bladder cells. This weakens the protective barrier of the bladder lining and makes it easier for E. coli to establish an infection. Excess sugar in the urine may also provide a more hospitable environment for bacterial growth.

Catheters and Medical Procedures

Indwelling urinary catheters are one of the most significant risk factors for UTIs in hospital and long-term care settings. Bacteria attach to the catheter surface remarkably fast, within less than two hours. Over the next 24 to 48 hours, these bacteria form complex communities called biofilms that coat the catheter and become highly resistant to antibiotics. Some bacteria within these biofilms enter a dormant state that allows them to survive antibiotic treatment and later reactivate, which may explain why catheter-associated infections often recur. The longer a catheter stays in place, the higher the infection risk, which is why healthcare teams aim to remove them as soon as possible.

Everyday Habits and Hygiene

You may have heard that wiping back to front after using the toilet causes UTIs by dragging fecal bacteria toward the urethra. This is widely repeated advice, but the evidence behind it is surprisingly thin. Neither the American Urogynecological Association nor the American College of Obstetricians and Gynecologists includes wiping direction in their UTI prevention recommendations. The skin around the genitals is already colonized with fecal bacteria regardless of wiping habits.

What does matter is hydration. Drinking enough water increases urine output, which physically flushes bacteria from the urethra and bladder before they can establish an infection. Consistently low fluid intake means less frequent urination and more time for bacteria to multiply.

Do Cranberry Products Help?

Cranberry products have a modest but real effect on UTI prevention, at least for women who get recurrent infections. A large Cochrane review found that cranberry products overall reduced the risk of a confirmed UTI by about 30% compared to a placebo. The benefit was strongest for cranberry tablets or powdered supplements, which cut the risk roughly in half for women with recurrent UTIs. Cranberry juice alone showed a smaller, less statistically reliable benefit, possibly because people don’t drink enough of it consistently or because the sugar content of commercial juices dilutes the active compounds. Cranberry products work best as a preventive measure, not a treatment for an active infection.

Less Common but Important Causes

Kidney stones or any structural abnormality that blocks urine flow can trap bacteria and lead to infection. Pregnancy increases UTI risk because the growing uterus presses on the bladder, and hormonal shifts alter the urinary tract. Immunosuppressive medications, whether for organ transplants, autoimmune diseases, or cancer treatment, lower the body’s ability to fight off bacterial colonization in the bladder.

In children, UTIs sometimes signal an anatomical issue like vesicoureteral reflux, where urine flows backward from the bladder toward the kidneys. In men under 50 who develop UTIs without an obvious cause like a catheter, an underlying structural or functional issue is worth investigating.