The longitudinal coupling impedance is obtained analytically for a smooth and resistive cylindrical pipe of finite wall thickness. We assumed a particle beam with Gaussian charge distribution in the longitudinal and transverse directions. For wall thicknesses d less than the skin depth, the impedance increases because of coupling with the vacuum outside the pipe, while for thicknesses d nearly of the order of the skin depth, the impedance becomes independent of the wall thickness. The resistive wall impedance decreases with increasing wall conductivity and it has its maximum values at low frequencies. By increasing beam energies, the space charge impedance decreases while the resistive wall contribution increases. Gaussian and uniform beams have nearly the same impedance at low energy, independent of the wall thickness, while at higher energies obvious differences are observed at wall thicknesses below the skin penetration depth.