Share your repls and programming experiences

← Back to all posts
🔥Minecraft Server on Repl.it!🔥
h
Scoder12 (882)

How to run a minecraft server on repl.it

Hey guys today I'm going to show you how to run a minecraft server on repl.it.

Note: You need hacker plan for this to work right now!

Installation is super simple!

  1. Fork this repl.
  2. Run the repl and follow the instructions.
    If you get any errors make sure that you typed everything right or try starting from scratch. Otherwise, comment and I may be able to help you.

Once you see Done! in the console, connect to the ip shown in ip.txt. If you don't want the IP to change you can purchase ngrok premium or use a dedicated minecraft host such as PebbleHost
If you have questions ask in the comments!

How to change minecraft version

  1. If you already have a server, delete the files mc/server.jar and mc.sh
  2. Run the command above that starts with wget again
  3. In mc.sh, find the line that says VERSION=1.16.3 and edit it to your desired version

If you get "signal: killed" or "OutOfMemoryError"

You have two options:
1. Buy hacker plan
2. Change the line at the bottom of mc.sh that starts with java to be java -Xmx1G -Xms1G -jar server.jar nogui" to "java -Xmx200M -Xms200M -jar server.jar nogui (thanks @gomgo)

Credits

Huge shoutout to @letsrepl for the initial concept.

Remember to upvote if you enjoyed!

Comments
hotnewtop
gg2001 (10)

Consider putting php -S 0.0.0.0:3000 ip.txt & bash mc.sh in main.sh, instead of just bash mc.sh. This automatically sets up a website for it, making it easier to use with uptime robot.

Once this is setup, go to uptime robot and create a keyword monitor that checks every 5 minutes for the keywords "Server running on". That way the server will stay up all the time.

Don't forget to put the ngrok_token and ngrok_region values in your .env!

Forgiving22 (1)

@gg2001 What IP should I use? How do I forward this ever-changing IP to a domain?

Scoder12 (882)

@Forgiving22 buy ngrok premium if you want to have an IP that doesn't change https://ngrok.com/pricing

astrochampcambr (1)

@Scoder12 are there any free alternatives to ngrok that have a static IP?

mesquite2234 (279)

@Scoder12 Could you use a Microsoft azure VM? (Not saying they're free, but they have a constant IP)

Scoder12 (882)

@mesquite2234 yes, you could do this on any VPS. Here is a tutorial. The one thing I would do differently from that tutorial is using a high-performance jar from https://papermc.io instead of the vanilla jar.

mesquite2234 (279)

@Scoder12 Thanks, how do I connect it to repl?
Edit: sorry for the unclear question, I meant to say how would I replace the ngrok thing with a VM

Scoder12 (882)

@mesquite2234 I don't know, it would probably require reverse proxies and stuff and would get pretty complicated

mesquite2234 (279)

@Scoder12 I have the code to start it, its the connecting from minecraft thing I needed help with.

mesquite2234 (279)

@Scoder12 I figured out the commands to start and run the server, but I can't connect to a server when I run it on replit, How do I connect?

mesquite2234 (279)

@Scoder12 I dont see one,where is it?

Scoder12 (882)

@mesquite2234 in the file ip.txt in the mc folder once you run the server

mesquite2234 (279)

@Scoder12 I have my own code for running the server, how do I find the IP? (Again, sorry for the unclear questions)

Scoder12 (882)

@mesquite2234 well if its not my code then you can google an ip finder service for the commandline, get your server's IP, and if your azure VM doesn't have any firewalls interfering with it you should be able to connect

mesquite2234 (279)

@Scoder12 I invited you to my repl, I need help connecting to this

LeoXu2 (43)

@gg2001 doesn't work for me. after it starts it just shows this ;-;

SGlive (0)

@gg2001 i tryes adding that line to mc.sh but webpage dies when server lodes ****sry fr bad English

Onetopic (5)

excited villager noises

zhidao (15)

I actually made a server!!! You have to make a .env file beforehand and it will work!

zhidao (15)

@zhidao

and plus, I have Minecraft

ThomasHagan (3)

how did you make the .env file? @zhidao

zhidao (15)

@ThomasHagan

bruh

just make a .env file named .env and put ur ngrok token inside

ThomasHagan (3)

@zhidao I tried that. I'll start again and create the .env file first as you mentioned. I was thinking there was something in the naming I may have been missing. Thanks!

zhidao (15)

@ThomasHagan no the .env file is lit named ".env"

ThomasHagan (3)

@zhidao Thanks! Felt a bit dumb to find that out.

JadenTheDev (1)

@ThomasHagan just make a new file and call it .env

Coder100 (18903)

ree not work here

basically whats the ngrok key reee

Scoder12 (882)

@Coder100 You have to login to the dashboard that it gives you, and then copy the auth token

Coder100 (18903)

ok what do i log in with i don't want to make acc reee @Scoder12

OverdriveAR (1)

mine won't run...

mc.sh: line 114: 376 Killed

what does this mean?

Scoder12 (882)

@OverdriveAR It means you don't have hacker. Adjust the memory settings according to the comment about it or buy hacker.

angrydoge (481)

Just set up this server then realized that this is a java server after waiting 5 minutes wondering why it wasnt connecting.

JasperLianLian (1)

@Scoder12 How do you do this I couldn't find any .env file

Scoder12 (882)

@JasperLianLian click main.sh then press the add file button and type .env and then press enter

CroxyTheDev (3)

it says "chmod: cannot access 'jre/bin/java': No such file or directory" please help me dude

Scoder12 (882)

@CroxyTheDev sorry, should be fixed now if you try again

yadunandanrocks (1)

When is the minecraft Bedrock server coming out? I can help you test it if required

[deleted]

@yadunandanrocks i also want a minecraft bedrock server on repl

Scoder12 (882)

@yadunandanrocks not sure, I don't know how to set it up tbh

DiveshTheReal (104)

i just create the server and got this Can't keep up! Is the server overloaded? :/

APCSPShehadaK (1)

Hey, any way to keep the server alive? The server closes very quickly even with hacker plan, I even lost ~5min of progress (autosave).
I wasn't able to listen to port 8080 & host the mc server at the same time as the http server would close as soon as the mc server started.

Any suggestions or plans?

Unrelated: Inside of your server.properties, I'd recommend setting sync-chunk-writes=false to improve performance & enable-rcon=false as rcon is not being used.

Scoder12 (882)

@APCSPShehadaK its very tricky to have multiple ports listening on repl.it and have the correct one be forwarded but you might be able to get it to work.

APCSPShehadaK (1)

@Scoder12
Solved with a vanilla php server on port 3000.
index.html is a placeholder, the file can hold anything but should exist.

main.sh:
php -S 0.0.0.0:3000 index.html & bash mc.sh

PokeGirl1024 (2)

Can you do this without Hacker? I'm a random kid wanting to play Minecraft and I've already used my savings for that.

Scoder12 (882)

@PokeGirl1024 You can use the Student Developer Pack to get hacker for free

DarshanRajpara1 (15)

Does it work for bedrock too?

tussiez (1676)

@DarshanRajpara1 If you could find low-level access to the Linux host of the Repl servers, yes. I'm still not sure if you can. With third-party hosts like PocketMine that runs on PHP, I bet you could.

Scoder12 (882)

@DarshanRajpara1 Someone was asking for help with a bedrock server using pocketmine, but they were having trouble connecting. I think thats its definitely possible in theory but hasn't been pulled off yet

EdenBabbage (0)

I followed the steps but am now getting "exit status 1", not sure what the problem could be as I am an inexperienced programmer but the version also changes itself back to 1.16.3 when I run the program?

Kingq23 (41)

@Scoder12 line 51 does not work also I think I have a way to get 1.17.1 working

Scoder12 (882)

@Kingq23 I admit that line 51 is a hack but it has worked in my testing. What issues are you seeing? What did you do to get 1.17 working?

Kingq23 (41)

@Scoder12 put pkgs.jdk16_headless in the nix files

Scoder12 (882)

@Kingq23 ah, awesome! I will update the post.

Kingq23 (41)

@Scoder12 51 does not work for me

Scoder12 (882)

@Kingq23 you said that already, can you give me an example so I know how to fix it?

Kingq23 (41)

@Scoder12 sorry i don't know bash i knew how to start the jar file not fix line 51. Sorry

Scoder12 (882)

@Kingq23 but how do you know it doesn't work

Kingq23 (41)

@Scoder12 this 'wget -O mc.sh https://xpiredl.scoder12.repl.co/mc.sh && bash mc.sh
Connecting to xpiredl.scoder12.repl.co (34.120.194.28:443)
saving to 'mc.sh'
mc.sh 100% |****| 3535 0:00:00 ETA
'mc.sh' saved
mc.sh: line 51: python3: command not found
exit status 127'

Scoder12 (882)

@Kingq23 ah my bad, try adding pkgs.python39 to packages

Kingq23 (41)

@Scoder12 now this does not work 'orig_server_ip=curl --silent http://127.0.0.1:4040/api/tunnels | jq '.tunnels[0].public_url''
error:'mc.sh: line 99: jq: command not found
exit status 127

'

Kingq23 (41)

@Scoder12 now line 99 is not working. is there a curl pacage

Scoder12 (882)

@Kingq23 yeah there is curl and jq just search it on https://search.nixos.org

Ninjax3 (0)

@Scoder12 how to upgrade to 1.17.1

Scoder12 (882)

@Ninjax3 works now, fork again

seddaouielias3 (0)

can we play cracked minecraft on it

Scoder12 (882)

@seddaouielias3 yes, lookup a tutorial on it but it basically just involves editing server.properties in the mc folder.

ASFNP (0)

what if it is a snapshot

AnimatingCoder (0)

I keep getting Failed to download vanilla jar javax.net.ssl.SSLProtocolException: Received close_notify during handshake. Is there a fix for this?

Scoder12 (882)

@AnimatingCoder not that I am aware of sorry. You may want to raise this issue with the paper team.

DArkENDoom (0)

1.17 doesn't work... any fix??

Kingq23 (41)

@Scoder12 how do i do this with 1.17

Kingq23 (41)

@Scoder12 every time I use it I get an error

Scoder12 (882)

@Kingq23 oh yeah that one I have no idea how to solve that one sorry. Hopefully it will fix itself eventually.

Scoder12 (882)

@Kingq23 works now, fork again

Starmanx64 (0)

Hi. I can't seem to be able to solve this error. I've redone the process multiple times, but I still seem to not be able to get past this point

Here's my repl if you need it https://replit.com/@Starmanx64/nix-java-16-1-1-1-1-1-1-1-1

Scoder12 (882)

@Starmanx64 That is really odd, I can't seem to fix it either.

EMAN6 (0)

I tried to run a 1.17 server with the link provided. (nix java 16) I find that it is still on java 11, and cannot run 1.17.

0rkx (0)

1.17 dosent work

Scoder12 (882)

@0rkx unsurprising since paper 1.17 isn't out yet. If you're desperate you can use the vanilla jar but it will be slower

0rkx (0)

@Scoder12 its out
also it says java 16 is not found

Scoder12 (882)

@0rkx works now, fork again

BIGcheeser (0)


idk what happened i think it might bc im signed out of mc?
@Scoder12

Hasibix (0)

how to make it bungeecord i just need to know how to make a bungeecord proxy on replit i know how to connect the servers

DillonB07Alt (1)

Would it be possible for you to create a mc.sh program for Fabric please?

I tried modifying it myself, but it didn't work.

supersecretfry (0)

Paper doesn't support 1.17 yet. Any suggestions?

Scoder12 (882)

@supersecretfry it was literally released today relax

DillonB07Alt (1)

@Scoder12 Paper doesn't support the current Java version(11) anymore. You need to update it to 16. For 1.17 servers that is.

supersecretfry (0)

@DillonB07Alt How would I update Java on Replit?

DillonB07Alt (1)

@supersecretfry I don't know. I think I was replying to @Scoder12

Scoder12 (882)

@supersecretfry I updated the post to mention this