As a runner, your feet are subjected to a lot of indignities. Sweaty socks, dirty shoes, and all that impact. So much impact. Every time you slam your feet into the ground, that force travels all the way up your body—but it’s your feet that bear the brunt of the abuse, which is why so many runners are well acquainted with one of the more unpleasant effects of running: black toenails.

What Causes a Black Toenail?

First, let’s go over some basic anatomy: Your toenails (and fingernails) come from something called the nail bed. “If you look at the base of your fingernails, you can sometimes see a little white half moon section called the lunula,” explains Daniel Paull, M.D., an orthopedic surgeon and sports medicine expert. “This is part of the nail bed, and where the nail itself comes from.”

OK, back to the effects of running. When you’re logging long distances or running at high intensities, it’s inevitable that your toenails will bang against the front, top, or sides of your shoe’s toebox. “This usually happens during the push-off phase when the toes are extended and hit the top of the shoe,” says Paull. Add to that the fact that your feet swell when you run, and you’ve got a situation that’s ripe for microtraumas to occur, explains Suzanne Fuchs, DPM, a foot and ankle physician and surgeon specializing in sports medicine.

When your nail turns black or blue, “it’s because those microtraumas have caused small blood vessels to rupture,” says Paull. Your nail is really only stained or appears discolored; “what you’re seeing, at least initially, is a collection of blood beneath the nail,” he adds. “The medical term for this is a subungual hematoma.”

What Actually Makes the Toenail Fall Off?

When enough blood collects beneath the nail, it starts to separate the nail from the toe itself. “In other words, the blood is pushing the toenail off of the toe,” says Paull. “The toenails are attached to the toe around the edges, and when enough blood collects, it creates enough force to separate the nail.”

BTW, if your toenail turns white, like the tip of your fingernails, without any black or blue coloring, that could also mean the nail plate has separated from the nail bed, says Fuchs.

What Should You Do About a Black or Loose Toenail?

Don’t let a slight discoloration freak you out; that probably doesn’t mean you're going to lose your toenail. “If the hematoma covers less than a quarter of the nail, just keep an eye on it—it should completely grow out within 10 months or so,” says Fuchs.

If your entire toenail is a casualty to the effects of running and you aren’t in a lot of pain, then you can probably just wait for it to grow back. “Toenails generally grow at about one-third the rate of fingernails,” says Paull. “Some accounts say that it takes 12 to 18 months for the toenail to grow out fully.”

But if more than a quarter of your nail is discolored, “I recommend runners see a foot specialist immediately,” says Fuchs. “The blood may need to be drained or the nail removed.” That much blood could mean the nail bed is lacerated or ulcerated (AKA torn, cut, or with an open sore), says Fuchs, and in this case, you need to see an orthopedic surgeon to suture the nail bed back together so your nail will grow out properly again, says Paull.

Whatever you do, don’t just wait for the nail to fall off if you’re experiencing any kind of pain or discomfort. “As a runner, your feet are everything,” says Fuchs. “Go see a specialist in order to prevent problems later on. You don’t want to not take any chances with increased irritation or infection.” And if you totally ignore toenail issues, you might end up with permanently thick, brittle, and discolored nails which are more susceptible to hard-to-treat fungal infections, Fuchs says (gross).

How to Prevent Black Toenails

Don’t think you’re in the clear just because you’re not marathon training. “I usually see these issues in people who are long-distance runners or who run at least four miles every day, but they can occur in anyone who runs,” says Fuchs. Losing toenails may be one of the less sexy side effects of running, but it is pretty common.

In running, the microtrauma that leads to black toenails mostly has to do with shoe fit, says Paull. “That’s why it is important to have a shoe that fits well and has a large toe box, which will give your toes more room and decrease the incidence of microtrauma,” he says. “Cutting your toenails also helps, as long toenails can make the rubbing worse.”

You can also add extra protection to your feet. “Some socks have an area to cushion or protect your toes,” says Fuchs. “There are also toe coverings or caps that you can place on your toe to absorb the shock and protect the nail.”

Just know that the farther you run, the more microtrauma to the toes you are potentially inducing—and black toenails or toenails that go MIA may be a regular part of your routine.