The engineering of topological nontrivial states of matter, using cold atoms, has made great progress in the last decade. Driven by experimental successes, it has become of major interest in the cold-atom community. In this work we investigate the time-reversal-invariant Hofstadter model with an additional confining potential. By calculating a local spin Chern marker we find that topologically nontrivial phases can be observed in all considered trap geometries. This holds also for spin-orbit-coupled fermions, where the model exhibits a quantum spin Hall regime at half filling. Using dynamical mean-field theory, we find that interactions compete against the confining potential and induce a topological phase transition depending on the filling of the system. A further effect of strong interactions yields a magnetic edge, which is localized through the interplay of the density distribution and the underlying topological band structure.