It all comes down to IP addresses in the end. For testing and local hosting it’s a great method for connecting and hosting a server.
If you don’t want to use that I suggest implementing a Online-Sub-System. These add additional features when hosting on a specific platform. Epic and Steam has one if I am not mistaken. I suggest looking at this thread for a deeper dive into this: Advanced Sessions Plugin