The corrosion inhibition properties of synthesized pyridine derivatives, namely, 4-(4-methoxyphenyl)-5,6-dimethyl-2-morpholinopyridine-3-carbonitrile and 4-(4-methoxyphenyl)-5,6-dimethyl-2-piperazinyl-pyridine-3-carbonitrile on N80 steel in 15% HCl solution were studied using gravimetric measurement, potentiodynamic polarization and electrochemical impedance spectroscopy techniques. The inhibition efficiency was found to increase with increasing inhibitor concentration and decreases on increasing the temperature from 303 to 333K. Some thermodynamic and kinetic parameters were calculated and discussed. The adsorption of inhibitor on the N80 steel surface obeys the Langmuir adsorption isotherm. Polarization studies showed that both the inhibitors behave as a mixed-type inhibitor. Scanning electron microscopy, energy dispersive spectroscopy, Fourier transform infrared spectroscopy, ultraviolet–visible spectroscopy and atomic force microscopy were performed for the surface study of uninhibited and inhibited N80 steel samples. The density functional theory was employed for theoretical calculations. Copyright © 2014 John Wiley & Sons, Ltd.