Adventures in Starting a Minecraft Server

Ever since I started playing Minecraft at the end of the summer, I have wanted to start my own server.  Unfortunately, it’s pretty much taken me this whole time to accomplish that.  So, I thought I’d post a small tutorial here in case anyone else is having similar problems.

First of all, my goals exactly.  I wanted to get the paid version of the Minecraft server up and running on an Ubuntu server that I had otherwise used as a web server.  I wanted to have multiple people be able to connect to this server through external ip addresses.  If you’re looking to do something similar, see if this helps.

First you’ll need to install Java if it’s not installed already.  You might be able to do this by typing

sudo apt-get install sun-java6-jre

But, if you can’t find the right package, just Google it, the exact names change all the time.

Now you’ll need to open port 25565, the default port used by Minecraft.  This port in NOT open by default, so you won’t be able to connect to your server without opening it.  Fortunately you can open it quite simply using iptables, the linux kernel firewall.  Just type the following lines:

/sbin/iptables -I INPUT -p tcp –dport 25565 -m state –state NEW,ESTABLISHED -j ACCEPT
/sbin/iptables -I OUTPUT -p tcp –sport 25565 -m state –state ESTABLISHED -j ACCEPT
service iptables save

Finally, copy minecraft_server.jar over to whatever directory you want on your server.  This is the file you get from http://minecraft.net/download.jsp, if you’ve paid for the game of course.  Now you can use the command to start the server that Notch gives on the same page:

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

As long as the responses coming back on the terminal show the server starting, you are set to connect to your server.  Open up Minecraft, go to multiplayer, and type in your ip address.  You should connect and be playing on the server.  Give some friends your ip address to joing and have fun.

 

Troubleshooting:

  • If you are still having problems connecting, you may want to try rebooting your server to make sure it opens port 25565 correctly.  Opening this port was my biggest problem in getting my server started.

 

  • In case you get errors saying ‘can’t reserve enough space on the heap’, you can scale back the two memory values and write something like:

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

Which will allow the server to start, but it may not run all that smoothly on less RAM.

 

  • If your server is running behind a router, opening port 25565 in iptables probably won’t be enough.  You’ll need to forward that port in your router, which you might be able to accomplish with the help of portforward.com.