A hysterosalpingogram (HSG) is an X-ray dye test used to diagnose problems related to fertility. During the test, an X-ray records images of the uterus and fallopian tubes while they’re filled with a special dye. The test can help diagnose issues in the reproductive anatomy that may prevent pregnancy, such as blocked fallopian tubes and an irregularly shaped uterus. HSG is also used a few months after some tubal sterilization procedures to make sure that the fallopian tubes have been completely blocked. The procedure is done in a hospital, clinic, or the office of your ob-gyn. The test is relatively safe, but all procedures have risks. You may have problems if you have an allergic reaction to the dye in the fluid. Pelvic infection or injury to your uterus are also possible. The most uncomfortable side effect of an HSG test is cramping, and your provider may recommend that you take over-the-counter pain medicines for a. The test usually takes less than 5 minutes, and you can go home the same day. It is best to have HSG done in the first half of the menstrual cycle (days 1 to 14) .