I never used to have this issue, I would just be able to press “Attach to Unity” and it would work, now I always have several ports and sometimes none of them work:

Unity 2021.3.13f1.
How can I identify which port Im supposed to use? Its a pain trying to figure it out every time. Especially since it doesnt always work.
Are you using an older version of Visual Studio? The dialog should look a bit different nowadays (and would show which one you would want to attach to).
Yes, 2017 is the only VS that runs smoothly on my computer.
Yeah, that makes it tricky. In 2019, we split Unity into several processes and added additional metadata that is broadcast to debuggers so they could display what is what. Unfortunately VS2017 shipped before then and thus doesn’t display the extra info :/.
I find it surprising that VS 2017 runs better than VS 2019 on your machine. From my experience they were pretty similar.
Have you tried VS 2022? That runs even better since it’s now actually 64-bit.