What is of concern, generally speaking, is your debt service ratio. The costs to maintain the tech relative to the benefit it brings.
If you derive significantly more benefit than the maintenance cost then your tech debt is healthy. As costs start to approach the benefit, or worse exceed it, then you have a problem. Either you need to settle your debts (give back the tech to the nothingness you borrowed it from), or refinance at a lower rate.
A complete rewrite repays the old debt and takes on new debt in hopes of a new lender providing a lower rate, but not only does this not eliminate debt the new lenders can be tricky and squeeze you when you’re not looking, more often than not leaving you with an even higher rate. The devil you know can certainly be beneficial.