There are three main reasons why you’re friends cannot connect to your Minecraft server.
If you’ve rented a server from a hosting company sometimes they have whitelists for which Minecraft usernames can connect.
To find out if the rented server has a whitelist your best off contacting your hosting company and seeing if there is one and if so if they can add your friend’s usernames so they can connect.
Wrong IP Address
If you’ve set up a Minecraft server at home. Then your friends must connect using your public IP address rather than the internal IP that you can connect from.
To find out your public IP address you’ll need to do a quick google search for ‘my public ipv4 address’ this will tell you the IP address which your friend will have to use to connect to the server.
Port not opened
Some ISPs close all the ports to stop anyone connecting to your network from the outside.
You’ll need to do what’s known as port forwarding. It’s quite a complicated process but there are hundreds of videos on youtube showing you how to do it. Just search ‘Minecraft server port forwarding’.
95% of people who’s friends cannot connect to their Minecraft server run into one of the three problems. If none of these solved your problem then there are dozens of different possibilities.
However, if you’re able to connect to the server then this normally means that it’s either a user whitelist or port forwarding problem.