The present publication discloses a method for coating pipes. The method comprises applying curable first polymer (e.g. epoxy) onto the surface of the pipe and partially curing the first polymer or leaving the first polymer uncured to in order to form a reactive first polymer layer. Thereafter, the pipe with the reactive first polymer layer is heated and a second polymer (e.g. polyolefin) is applied directly onto the heated reactive first polymer layer, whereby the two polymers react and form a protective coating on the pipe or pipe section. In particular, the heating can be carried out in two steps such that the first polymer stays reactive until the application of the second polymer.