Can't play or connect to friends

I can play all game types by myself no lag and no problems but when I even try to join my friends in a custom it says unable to join connection timed out. When we try to play online it gives a similar message and says waiting to join but doesn’t do anything. Wondering if there’s a way to fix this with like opening a port or something. Thanks.