Thanks for all your replies!
...one similar mistake I was making when I wrote my miner in early stages was that I was changing the difficulty of the already mined block which in turn changed the hash that was found and made it incorrect.
yeah I'm aware of this fact, this is not the problem.
You also keep saying "leading zeros", we don't deal with "leading zeros" at all in difficulty. Instead we deal with numbers. 05 is bigger than 03 but both have 1 leading zero, which could be another reason why your block was rejected.
yeah, also about this I'm aware, I just call it "leading zeros" because for humans it's easier to check.
But my script is calculating the target out of the difficulty bits, and comparing the height of the hash (as number) against it.
So also this is not the problem.
I quickly was setting up a local Regtest Net with two nodes, and the mining is working fine and the blocks are accepted.
Seems on testnet, it is/was just a timing issue that some other guy submitted his block faster...
Cheers