Constipation occurs when you have fewer than three bowel movements in a week, or have bowel movements that contain hard, dry stools that are difficult or even painful to pass. In some cases, constipation makes it feel as though you’re unable to completely empty your bowels. Treatment for constipation depends on its severity, duration (acute or chronic), and cause — which can include a range of factors, from a low-fiber diet to medications to other health issues.

Dietary and Lifestyle Changes

Lack of fiber in the diet is often the cause of constipation. The Academy of Nutrition and Dietetics recommends that adults get 25 to 38 grams of dietary fiber each day. But only 5 percent of the population actually reaches this goal, with the average intake being just 17 grams per day, according to a 2015 report in the Journal of the Academy of Nutrition and Dietetics. Getting the right amount of fiber — through eating more fruits, vegetables, beans, and whole-grain cereals and breads — can help alleviate constipation. Regularly drinking water and other healthy beverages is also important for constipation relief, as the liquid can help make fiber more effective at maintaining regularity, according to the National Institute of Diabetes and Digestive and Kidney Diseases (NIDDK). Other lifestyle changes can also help relieve or prevent constipation, including:

Exercising regularlyTrying to have a bowel movement at the same time every day, such as 15 to 45 minutes after breakfast (eating stimulates colon activity)Reserving enough time to have a bowel movementNot resisting the urge to have a bowel movement

Laxatives and Other Medications

If dietary and lifestyle changes alone are unable to fully relieve constipation, laxatives may help — but you shouldn’t take any constipation medications before discussing your options with your doctor. Commonly used laxatives include:

Bulk-forming laxatives, such as Citrucel (methyl cellulose), FiberCon (polycarbophil), and Metamucil (psyllium), which absorb fluid in your intestinesOsmotic and saline laxatives, such as Miralax (polyethylene glycol), Cephulac (lactulose), and Milk of Magnesia (magnesium hydroxide), which draw more water into the intestines and stoolStool softeners, such as Colace or Surfak (docusate), which help moisten stool to reduce the strain of bowel movementsLubricants, such as Fleet or Zymenol (mineral oil), which grease the stool to allow it to move more easily through the intestines

If your constipation is severe or other laxatives are ineffective, stimulant laxatives may help. These medications, which include Senokot (senna or sennosides) and Dulcolax or Correctol (bisacodyl), cause the muscles lining the intestines to contract. If you have chronic constipation from irritable bowel syndrome, your doctor may prescribe other drugs, such as the chloride channel activator Amitiza (lubiprostone) or the guanylate cyclase-C agonist Linzess (linaclotide).

Surgery and Other Procedures

If you have chronic constipation caused by a bowel obstruction, your doctor may recommend surgery or other procedures to help treat the condition. A possible complication of constipation is rectal prolapse, which occurs when part of the rectum sticks out of the anus, further blocking your ability to empty your bowels. Surgery is often necessary to correct rectal prolapse. If your colon muscles don’t work properly — a condition called colonic inertia, or slow-transit constipation — your doctor may need to remove your colon. Chronic constipation is sometimes caused by a dysfunction of the anorectal muscles. Your doctor may recommend biofeedback, a procedure that involves monitoring muscle activity with special sensors, to retrain your muscles to work properly.