Apart from heredity, factors like excessive stress and anxiety, a deficiency of vitamin B12 and minerals like iron and iodine, chronic illnesses, smoking, pernicious anemia, vitiligo, thyroid problems, and the excessive consumption of coffee, alcohol, tea, and fried, oily, or spicy foods can play a significant role in causing premature graying of hair.