Modelling of molecular emission spectra from interstellar clouds requires the calculation of rate coefficients for (de-)excitation by collisions with the most abundant species. We calculate rate coefficients for the rotational and hyperfine (de-)excitation of the hydrogen cyanide (HCN) by collisions with H2 (j= 0), the most abundant collisional partner in cold molecular clouds. The scattering calculations are based on a new ab initio potential energy surface for the HCN–H2 collisional system, averaged over the H2 orientations. Close-coupling calculations of pure rotational cross-sections are performed for levels up to j= 10 and for total energies up to 1000 cm−1. The hyperfine cross-sections are then obtained using a recoupling technique. The rotational and hyperfine cross-sections are used to determine collisional rate coefficients for temperatures ranging from 5 to 100 K. A clear propensity rule in favour of even Δj rotational transitions is observed. The usual Δj=ΔF propensity rules are observed for the hyperfine transitions. The new rate coefficients are compared with the previous results obtained for the HCN molecule. Significant differences are found, mainly due to the use of H2 as a collisional partner instead of He. The new rate coefficients will significantly help in interpreting HCN emission lines observed with current and future telescopes.