Metal–hydrogen systems have been continuously investigated due to the ability of metallic atoms to absorb large amounts of hydrogen. According to this viewpoint, the electronic structure, elastic and phonon properties of perovskite hydrides MgXH3 (X = Fe, Co) are searched using ab initio calculations based on density-functional theory (DFT) in this study. The lattice constants, bulk modulus, second order elastic modulus, anisotropy factors, Poisson's ratio, Young's and Shear moduli are calculated. From the elastic constants, both hydrides were found to be stable mechanically. According to obtained results, MgFeH3 and MgCoH3 can be classified as brittle and ductile material, respectively. Both hydrides show a metallic character due to very strong electron phonon interaction. The electronic band structures, phonon dispersion curves, the corresponding total and partial density of states (DOS), as well as the specific heat capacity, entropy and phonon free energy in terms of temperature are also researched for the first time in this study.