How Do You Get a Urinary Tract Infection?

UTIs happen if bacteria enter the urethra and cause painful, cloudy urine that may smell.

Urinary tract infections (UTIs) commonly occur if bacteria enter the urethra, the duct where urine leaves the body. Several factors, like sexual activity and kidney stones, increase UTI risk.

Understanding how you might get a UTI and how it affects your body can help you deal with it. Here's what you should know about what causes a UTI and where the bacteria come from.

Getty Images

What Causes UTIs?

UTIs happen when bacteria infect the urinary tract after entering the urethra. The bacteria may come from a person's skin or rectum.

Escherichia coli (E. coli) is a bacterium that usually lives peacefully in your bowel but can lead to a UTI if it enters the urinary tract. Though E. coli causes many UTIs, infections can come from other bacteria (e.g., StreptococcusKlebsiella, and Proteus mirabilis) and fungi.

UTI treatments depend on the type of pathogen causing the infection. A healthcare provider can obtain and send a urine sample for testing to figure out what pathogen is the culprit.

What Is an Upper UTI?

A UTI could eventually lead to an upper UTI if untreated. You get an upper UTI if the bacteria travel up your ureters and invade your kidneys. An upper UTI can cause permanent kidney damage or even sepsis, a life-threatening infection.

Typically, UTIs cause painful urination and cloudy or bloody urine. In addition to those symptoms, look out for upper UTI symptoms, such as:

  • Fever
  • Chills
  • Pain on your side, back, or groin
  • Vomiting
  • Nausea

Who Gets UTIs?

All people have urethras and bladders, making them vulnerable to bacterial infections. Still, certain factors increase the risk of UTIs, such as:

  • Older age
  • Anything blocking the flood of urine
  • Bowel incontinence
  • Health conditions affecting personal care habits, like Alzheimer's disease
  • Diabetes
  • Having a urinary catheter
  • Kidney stones
  • Menopause
  • Pregnancy
  • Problems emptying the bladder
  • Procedures involving the urinary tract
  • Staying still or being immobile

UTIs and Biological Sex

UTIs also tend to happen more often in females than males. The urethra in females is usually no more than about 1.5 inches long. In comparison, the urethra in males stretches between seven to eight inches long.

In males, bacteria have to travel much farther to infect the bladder or other parts of the urinary tract. Urine can flush out bacteria before they can colonize.

For females, the urethral opening is located between the labia in front of the vaginal opening, which is close to the anus. Since the male urethral opening is on the tip of the penis, it is less likely to come in contact with any bacteria from the anus.

Common Causes of UTIs

E. coli or other pathogens are the culprits of UTIs. A few behaviors impact a person's risk of UTIs and how the bacteria reach the urethra, from kidney stones to wet bathing suits.


Engaging in sexual activity can result in a UTI. A person could accidentally spread bacteria into their or their partner's urethra during sex.

For example, using some birth control methods during sex—namely, spermicides and diaphragms—can increase the risk of UTIs. Diaphragms can slow the flow of your pee, while spermicides can irritate your skin.

To reduce the likelihood of UTIs, urinate before and after sexual activity.

Wiping From Back to Front

In females, wiping back to front after urinating increases the risk of UTIs. Wiping that way can drag any bacteria in the anal region to the urethra. Therefore, wiping front to back can help prevent UTIs.

Kidney Stones

Kidney stones are hard deposits that can cause a UTI if they block your urinary tract. Blockage makes it difficult to fully release all your pee, creating a breeding ground for bacteria.

Holding Your Pee

Holding your pee can often create an environment for bacteria to thrive and infect your bladder. Urinating or trying to urinate if it's been three to four hours may lessen the risk of UTIs.

Wet Bathing Suits

Sitting in a wet bathing suit will not directly cause an infection. A wet bathing suit can cause a UTI by creating a bacteria-friendly environment. 

The same goes for damp underwear or sweaty gym clothes. Keep any clothing near the vagina or penis dry by changing wet clothing to avoid bacteria.

A Quick Review

When bacteria enter a person's urethra, a UTI can occur. UTIs can go beyond the bladder and affect the kidneys if untreated. Anyone can develop UTIs. Factors like diabetes, immobility, and older age can increase UTI risk.

Causes of UTIs include prolonged wear of wet clothing or wiping from back to front. Regardless of how you got a UTI, paying attention to it is essential. Consult a healthcare provider as soon as possible if you have symptoms of a UTI.

Was this page helpful?
11 Sources uses only high-quality sources, including peer-reviewed studies, to support the facts within our articles. Read our editorial process to learn more about how we fact-check and keep our content accurate, reliable, and trustworthy.
  1. Centers for Disease Control and Prevention. Urinary tract infection.

  2. Centers for Disease Control and Prevention. Questions and answers.

  3. Merck Manual Professional Version. Bacterial urinary tract infections.

  4. MedlinePlus. Urinary tract infection - adults.

  5. Bono MJ, Leslie SW, Reygaert WC. Urinary tract infection. In: StatPearls. StatPearls Publishing; 2023.

  6. National Institute of Diabetes and Digestive and Kidney Diseases. Symptoms & causes of kidney infection (pyelonephritis).

  7. Abelson B, Sun D, Que L, et al. Sex differences in lower urinary tract biology and physiologyBiol Sex Differ. 2018;9(1):45. doi:10.1186/s13293-018-0204-8

  8. MedlinePlus. Vagina.

  9. Eunice Kennedy Shriver National Institute of Child Health and Human Development. What causes UTIs & UI?.

  10. Office on Women's Health. Urinary tract infections.

  11. MedlinePlus. Kidney stones.

Related Articles