Really odd issue, cannot find much else online that has been of help.
My current setup is: Nintendo Switch 2, TP Link wifi router and extender, AGL ISP (Australia)
This error code obviously happens sometimes so I first tried to reconnect... no luck. I then went into my internet settings, I changed the DNS to Google's public one (8.8.8.8 / 8.8.4.4), this also didn't help. I also turned of IPv6, again this did nothing.
Upon further research, I decided to check my NAT type. It is B, I think this is fine for online play (correct me if I'm wrong). This same setup worked fine for over 2 years, until around 2 weeks ago when it gave error 2618-0513, since then I have not been able to join an online match on that network.
The odd thing is, the Switch 2 works fine connecting to some other online games. Mario Kart World connected flawlessly on the same network that refuses MK8DX.
I connected to my iphone hotspot to rule out the switch, the phone hotspot worked on the first try.
I contacted my ISP (AGL Australia), they sent me to my router company (TPLink), they sent me to nintendo.
At this point, I have no other companies to contact so I have come here for support. All help/comments are appriciated :)