The heavy metal pollution caused by widespread industrial activities is an important and difficult issue for environmental pollution control in China. It adversely affects human health and the ecosystem. However, the relevant research on heavy metals contamination in typical petrochemical (PIA) and coking industries areas (CIA) was few. In this study, a total of 24 and 21 surface topsoil (< 20 cm) samples were collected in petrochemical and coking industrial areas, respectively. The geo-accumulation index (Igeo), enrichment factor (EF), and potential ecological risk index (ERI) were calculated to assess the Cu, Pb, Ni, Co, Cr, Zn, V, and Mn pollution levels in soils. The hazard index (HI), carcinogenic risk (CR), and non-carcinogenic risk (NCR) were used to assess the human health risk of heavy metals. The mean levels (mg/kg) of heavy metals were ranked as Mn (601.25) > Zn (154.63) > Cr (76.78) > V (76.04) > Cu (39.11) > Pb (36.88) > Ni (31.73) > Co (12.97) in PIA, and Mn (915.14) > Zn (307.64) > Cr (115.98) > Pb (93.20) > V (92.56) > Cu (44.42) > Ni (34.45) > Co (16.65) in CIA, respectively. Pollution indices indicated that the extent of heavy metals contamination in CIA soils is higher than PIA. Source apportionment of heavy metals in soil was performed using Spearman's correlation coefficient, principal component analysis (PCA) and matrix cluster analysis, suggesting that industrial activities and the transshipment process were the major contributors to heavy metals. About NCR, the THI values were higher than 1 in both typical industrial areas, implying that there is potential health risk to humans. Except for the CR values of Pb for children and adults in both industrial areas and the CR values of Cr for adults in PIA, the CR are between 1.00 × 10− 6 and 1.00 × 10− 4, other heavy metals of the CR values were higher than 1\(\times\)10−4. This result reflects the fact that there were seriously adverse impacts on human health. Overall, the NCR and CR of the heavy metals for different populations ranked as follows: children > adults and Cu, Ni, Co, and Cr were identified as the major contributors to CR and NCR. The result of the present study provides timely information for developing control and management strategies to reduce soil contamination by heavy metals in typical petrochemical and coking industries areas.