Allowing a friend to connect over the internet to a Minecraft server I've hosted?
I have set up a Minecraft server and have built lots of things, now I want my friend to play on it too.
I'm hosting it on my home computer and don't want to have to set up a new server elsewhere so I need to allow my server to be accessible over the internet.
How can I make this server available for my friend to connect to over the internet?
Here's what the scheme of things probably looks like:
┌───────────┐ ┌────────┐ ┌────────┐ ┌──────────┐
│ Your │192.168.0.2 │ Your │82.15.X.Y │ Friend │192.168.0.1 │ Friend │
│ computer ├─────────────┤ router ├───────────┤ router ├─────────────┤ computer │
├───────────┤ 192.168.0.1└────────┘ 78.13.Z.T└────────┘ 192.168.0.2└──────────┘
│ Minecraft ├ Port 25565
└───────────┘
└───────────────────────────┘ └───────────────────┘ └────────────────────────────┘
Your home network Teh Internets Friend home network
Your minecraft server is listening on port 25565 of your home computer, 192.168.0.2. However, this is a private address that only makes sense when connected to your router. Each router has its own private addresses, which means that your computer can be on 192.168.0.2, your friend computer can also be on 192.168.0.2 and everything is still okay.
To connect to you, your friend needs the IP address your router is connected to the internet with. Your ISP (more or less) dynamically assigns this number to you and it's what those "what is my ip" sites show to you. So, to your friend, you're 82.15.X.Y, and that's what he will enter on Minecraft.
However, 82.15.X.Y is not your computer, but your router. Your router doesn't know what to do with connections to that port and rejects the connection. What now?
Your router needs to know that, if he sees attempts to connect to port 25565 (Minecraft servers' default listening port), he should forward those connections to the computer on address 192.168.0.2 — this is port forwarding.
To make port forwarding work, you need two things:
- A static IP address in your home network. You can get this by configuring static allocation DHCP, so that your computer* always gets the same IP address (say, 192.168.0.200).
- The port forwarding information (forward all connections to port 25565 to 192.168.0.200).
The exact configuration process depends by your router make and model. Sites like portforward.com have extended guides to get this working.
* or, more accurately, the MAC address of your computer's network card.
An easy way I've found to let my friends connect to my Minecraft server, which is running on my own machine is to use a free tool called ngrok
to expose my server to the internet.
1) Download ngrok from http://www.ngrok.com. You'll need to signup for a free account as well, and follow their setup instructions.
2) Start your Minecraft server
3) To share your local Minecraft server, run the following in a terminal:
ngrok tcp 25565
4) This will display some information, with a line like the following:
Forwarding tcp://ngrok.com:XXXXX -> localhost:25565
Write down the number that's where the XXXXX is above.
5) Your server is now available on the internet! But how do your friends connect to it?
6) Tell your friends to start Minecraft, then
- click "Multiplayer"
- click "Direct Connect"
-
Fill in the following, replacing XXXXX the number you wrote down in step 4)
ngrok.com:XXXXX
7) They should now be connected to your Minecraft server!
TROUBLESHOOTING: Note - if it doesn't work, then instead of "Direct Connect", add it as a server by choosing "Add Server", then supply ngrok.com:XXXXX
. Then just connect to the server that way instead!