The presence of heavy metals in indoor dust is a world-wide concern owing to its negative impact on humans. In this study, we collected indoor dust samples from urban and rural residential areas during the heating season in Taiyuan City. We then identified the concentrations of 11 heavy metals (Cd, Co, Cr, Pb, Mn, Ni, Cu, Zn, V, As, and Hg) using inductively coupled plasma-mass spectrometry. Based on the concentrations, we categorized the pollution levels of indoor dust using the geo-accumulation index and the pollution load index. We further identified the sources of heavy metals using the enrichment factor and principal component analysis. Finally, we evaluated the potential ecological risks of heavy metals via the potential ecological index. The results illustrated that ① with the exception of Co, Mn, and V, the mean concentrations of Cd, Cr, Cu, Ni, Pb, As, Zn, and Hg in indoor dust were higher than the soil background values of Shanxi Province. There was a significant difference (P<0.05) in the concentrations of Co, Cr, Cu, Mn, Ni, and Hg between the urban and rural areas. ② Overall, the pollution degree of heavy metals in indoor dust was identified as moderate in the urban area of Taiyuan City, but slight in the rural area. The indoor dust sample in the urban area was not contaminated by Co, Mn, and V. However, it was slightly polluted by As, Ni, and Hg. In addition, it was close to moderately polluted by Cd, Cr, Cu, Pb, and Zn. In the rural area, the pollution degrees of all the metals, except for Hg and V, in indoor dust were lower than those in the urban area. ③ The As, Cd, Cu, Pb, Zn, and Hg in indoor dust for both urban and rural areas might have mainly originated from anthropogenic sources. The pollution sources were mainly transportation and industry in the urban area and coal combustion and indoor smoking in the rural area. The Co, Cr, Mn, Ni, and V in indoor dust in Taiyuan City might have mainly originated from natural sources. ④ The ecological risk of heavy metal pollution in indoor dust for both the urban and rural areas of Taiyuan City was relatively high, with integrated ecological risk indexes of 359.43 and 471.02 in the urban and rural areas, respectively. In addition, Cd and Hg were the largest contributors.