In this paper we discuss thermostatting using stochastic methods for molecular simulations where constraints are present. For so-called impulsive thermostats, like the Andersen thermostat, the equilibrium temperature will differ significantly from the imposed temperature when a limited number of particles are picked and constraints are applied. We analyze this problem and give two rigorous solutions for it. A correct general treatment of impulsive stochastic thermostatting, including pairwise dissipative particle dynamics and stochastic forcing in the presence of constraints, is given and it is shown that the constrained canonical distribution is sampled rigorously. We discuss implementation issues such as second order Trotter expansions. The method is shown to rigorously maintain the correct temperature for the case of extended simple point charge (SPC/E) water simulations.