How to Setup Free Minecraft Cloud Server Hosting - Archived

Alright todays super duper post is going to show you how to run your own Minecraft server on an OpenShift gear. There is no big introduction to this one since I am assuming most people have heard about Minecraft (if not then you need to come out from under that rock you are stuck under).


  1. A small gear is only 512 megs of RAM and so that is not going to let you allow many people to connect (notice on the server Download page they are using 1024 megs of RAM). We tested with 2 people on the same server and it ran completely fine with no lag.

  2. At this time, OpenShift is primarily a HTTP server platform – we proxy HTTP calls but no other protocols. In addition, we only expose ports 80 (HTTP), 443 (HTTPS), and 22 (SSH) to the outside world from your gear. While we can start up Minecraft Server on any port we want (and tell the client to listen on that port), the Minecraft server and client do not talk HTTP so we can not proxy the calls. To get this to work we are going to have to SSH port-forward either from your laptop to the server or vice versa (both configurations are supported on OpenShift).

  3. You will need to install the OpenShift command line tools to do this. Go sign up for an account and then install the client tools on your laptop or desktop machine.

All set? Good, let’s do this!

Server Set Up

1) Cd on your local machine to a dir where you want to create a local git repository.

cd git_repos

2) Create a DIY application. DIY applications are basically a blank cartridge on your gear that let you install any binary that will run on Fedora and RHEL.

rhc app create minecraft diy-0.1

3) Copy the ssh command from the output of the rhc command. At the end of the instructions you will see a long url that looks like:


Everything after the // to the .com is the address you are going to use with the SSH command. So in this example it would be

4) Go ahead and SSH into your gear in a terminal or command prompt and then cd to the data directory. To get SSH working on windows you will need to install PUTTY and Puttygen – we have all your documentation needs right here

cd diy-0.1/data/

5) Download the minecraft server to your data directory.


6) Now log out of your SSH session, using either ‘+d’ or ‘exit’

7) You now cd into the directory created on your local machine that represents the git source-code repository. The directory name should match the name of your application. Then cd into .openshift/action_hooks (.openshift\action_hooks on windows)

cd minecraft/.openshift/action_hooks/

8) Now we need to modify the start and stop hooks. Here is what you are going to make the to the file named ‘start’:

    open the file named 'start' with your favorite editor and paste in the follow contents.
nohup bash -c "exec 'java' '-jar' 'minecraft_server.jar' '-Xms256M' '-Xmx490M' '-nogui' &> ${OPENSHIFT_DIY_LOG_DIR}minecraft.log" &> /dev/null &  

then edit the file named stop and edit it to only have

killall java
exit 0

Both of these files are saved in an attachment to this blog post. You can just download them and unzip them into the correct location given aboves.

9) Send our changes up to the gear

git commit -am "adding action hooks"
git push

10) Check to make sure the server tried to start up and failed – this is actually a good sign.

cd diy-0.1/logs/

Then tail the minecraft.log file and you should see

2012-11-01 19:52:58 [INFO] Done (42.296s)! For help, type "help" or "?"
2012-11-01 19:53:06 [WARNING] Can't keep up! Did the system time change, or is the server overloaded?
2012-11-01 19:53:23 [WARNING] Can't keep up! Did the system time change, or is the server overloaded?

This is what we want to see. It means the server started but couldn’t bind to it’s default port which is as expected. If you don’t see those lines then please go back out to the command line on your local machine and do

rhc app force-stop

The other side effect is this now created a file in diy-0.1/data. We need to edit this so that the minecraft server binds to the right ports.

cd diy-0.1/data/

We are going to need to get the IP and port for our DIY cartridge. We can get these from the environment variables

env | grep INTERNAL

The output gives us is the IP address and port we need to bind to the Minecraft server. In my case it is


Now edit with your favorite text editor. I like to stay out of religious wars but vi seemed to work well for me.


change two lines in the file. Server-port needs to be changed to the value given above (8080)


and server-ip needs to be filled in with the IP address from above


Go ahead and save and exit the file. Now go back to the command line on your local machine and restart by typing -d or exit. Then restart the gear

rhc app start -a minecraft
Password: **********

Now ssh back into the gear and look at the log file again

cd diy-0.1/logs/
less minecraft.log

And it should look something like this

208 recipes
27 achievements
2012-11-01 21:06:07 [INFO] Starting minecraft server version 1.4.2
2012-11-01 21:06:07 [INFO] Loading properties
2012-11-01 21:06:07 [INFO] Default game type: SURVIVAL
2012-11-01 21:06:07 [INFO] Generating keypair
2012-11-01 21:06:10 [INFO] Starting Minecraft server on
2012-11-01 21:06:11 [INFO] Preparing level "world"
2012-11-01 21:06:11 [INFO] Preparing start region for level 0
2012-11-01 21:06:13 [INFO] Preparing spawn area: 3%
2012-11-01 21:06:14 [INFO] Preparing spawn area: 11%
2012-11-01 21:06:15 [INFO] Preparing spawn area: 24%
2012-11-01 21:06:16 [INFO] Preparing spawn area: 45%
2012-11-01 21:06:17 [INFO] Preparing spawn area: 81%
2012-11-01 21:06:17 [INFO] Done (6.702s)! For help, type "help" or "?"

ignore the warnings at the end this time – the important line is where it says it is starting up the server. As long as those match the IP address and port from before we should be good.

We now have our minecraft server running! Time to get our client machine ready to connect to it.

Getting the client machine connected to the Minecraft server

As I mentioned in the beginnng of this post – we will not be able to connect our local machine with the Minecraft client to the Minecraft server because of port-forwarding issues. But never fear – we can SSH tunnel into our gear and port-forward any outgoing network connections from our local machine to on port 8080 to the OpenShift gear. There is plenty of information about SSH port-forwarding also referred to as SSH tunneling. We are going to be using local forwarding, not remote forwarding.

If you installed the client tools to this then life is easy for you (though a little more work on a Mac). We have a blog post, an external blog post, and documentation that talk all about SSH port forwarding using the command line tools. Mac users (such as myself), because Mac OS is based off of BSD, you need to do a little more work to get this all going. Please be sure to read the documentation which explains nicely how to set this up on mac. Since I am on mac I am going to give those instructions here. For other systems you just need to run the RHC command.

1) Mac Only First you will need the IP address from the section where we installed the server. Then you put that into your ifconfig command on your local terminal

sudo ifconfig lo0 alias
(hint - the password here is the password for the account on your Mac)

2) Now you run the RHC command (I am using the newer syntax). Be aware that this will now tie up this terminal with the port forwarding

rhc port-forward -a minecraft
Password: **********

Checking available ports...
Binding java ->
Forwarding ports, use ctl + c to stop

Notice how it picked up the 8080 port which we are using for Minecraft server.

Normal SSH port forwarding

You could also do this with straight port forwarding not using the RHC command but that is a bit more involved. Read here to get some idea on how you would set that up with SSH for linux, mac, and Putty on Windows.

Connecting your minecraft client

3) Now just start up your Minecraft client and:

a) Click multiplayer (To avoid making the dumb mistake of the author, please note this option only comes up on the second screen AND only after you have paid for an account)
OpenShift Minecraft multiplayer picture

b) Click Add Server (You could also click direct connect)
OpenShift Minecraft Addsever picture

c) Put in the IP address with the port on the end as we saw in the rhc port-forward command. The name of the server can be anything you want – it is just there to help you remember the server.
OpenShift PaaS Minecraft server address picture


Adding friends to your server

While it is fun to play minecraft just by yourself it is even more fun when you play with others. Allowing a friend to play is simple, we just use normal SSH port forwarding.

You do this

1) Add their public SSH key to your OpenShift account either through the command line “rhc sshkey” command OR through the web console on the My Account Tab. You can read more about adding SSH keys here. Remember you want to add your friends SSH public (the one ending in .pub) key to your account.
OpenShift Paas Minecraft server add key picture

Your friends do this

2) A good test to see if they have it set up properly is to have them SSH into the machine using the same user and address that you used above. If it is set up properly they should be able to SSH into your gear running MineCraft.

3) Your friend now sets up an SSH tunnel to the machine. Read here to get some idea on how you would set that up with SSH for linux, mac, and Putty on Windows to set up the SSH tunnel to your server. The port we are going to forward is still 8080. So the SSH command for my friends trying to use my server would be:

ssh -N -L

4) Then in step C above for connecting the client they use This was tested with 2 Macs, so please let us know if it is something different on Putty with windows.

And there you have it, setting up your minecraft server and connecting a client – all for free. There are tons of ways to customize your server. Remember you are going to have to either SCP those changes up or wget them down to your gear. You can also change setting by SSH’ing in to your gear and changing setting in

Since I am generally new at running MineCraft (as in just started for this blog post), I would love to see other hints and suggestions in the commments here. I hope you and your friends have fun minecrafting!

What’s Next?

Java, OpenShift Online
, , ,
Comments are closed.