Is it impossible to find a PhD position for someone who has failed courses during their master's degree?
I will answer specifically for the German system, as that is one of the two countries the OP expressed interest in in the comments.
To enroll in a German PhD programme, you need the agreement of a professor to supervise you and (typically) an MSc in a related subject with (often) grades exceeding some threshold. Only the overall grade on your MSc certificate matters, not the individual modules.
Thus, the fact that you have some failed modules on your transscript will only matter for your admission to a German PhD programme indirectly, by impacting your ability to convince a professor to take you on as a student. There might be some professors for whom this is a deal-breaker, but there will also be some who don't much care; and certainly many who see it as a negative which can be overcome by other strengths.
It is worth pointing that failing modules is very common [or at least, used to be until not too long ago] in the German system (eg the math exam in computer science often have failure rates of 50%+). So I expect much less of a stigma carried by it than it seems to have in the US, for instance.