Non-adiabatic on-the-fly dynamics simulations of the photodynamics of formamide in water and n-hexane were performed using a QM/MM approach. It was shown that steric restrictions imposed by the solvent cage do not have an influence on the initial motion which leads to the lowest energy conical intersection seam. The initial deactivation in water is faster than in n-hexane and in the gas phase. However, most of the formamide molecules in water do not reach the ground state. The reason for the deactivation inefficiency in water is traced back to a decrease of close CO⋯HOH and NH⋯OH2 contacts which fall in the range of hydrogen bonds. The energy deposition into H-bond breaking events leaves molecules with less energy for surmounting the CN dissociation barrier. In both solvents, after hopping to the ground state, the solvent cage keeps the HCO and NH2 fragments or CO and NH3 products in close proximity. Consequently, the number of trajectories where fast recombination happens is augmented with delayed recombinations that start when the dissociation fragments hit the cage wall and return back. The hot ground state formamide is formed in an internal conversion process identical to the path leading to CN photodissociation. In the case of aqueous formamide, good agreement with experimental results is achieved by combining dynamics simulations starting from the S1 and the S2 excited states collecting high and low energy trajectories, respectively.