How to Set Up and Host a Free Minecraft Java Localhost Server

Learn How to Set Up Your Own Free Minecraft Java Server! A Step-by-Step Guide to Hosting and Customizing Your Multiplayer World

Want to host your own Minecraft server for free? This step-by-step guide will show you exactly how to set up a localhost Minecraft server for Java Edition on your computer. Hosting your own server allows you to customize your Minecraft experience, play with friends, and explore your favorite worlds without needing third-party hosting.

Whether you’re a beginner or looking for a cost-effective way to run a server, this tutorial will guide you through everything you need to know. Let’s get started on creating your very own Minecraft Java Edition server for free!

Quick Navigation

Why Host a Local Minecraft Server

A localhost Minecraft server for Java Edition gives you complete control over game settings, mods, and privacy. It’s a free and private solution, perfect for playing with friends or testing custom configurations. Plus, hosting your own server is an excellent way to learn about Minecraft server setup and management. However, there are some risks when running your own server, such as security vulnerabilities and performance limitations. For a simpler, reliable solution, consider Apex Hosting for professional server hosting.

Requirements
  • A computer with a stable internet connection
  • At least 1GB of free RAM (more is recommended for better performance)

Step 1: Install the Latest Version of Java

If you haven’t updated Java lately, this is the moment to do so, we have an article on How to Install Java 21 you can read. However, here is a simple way to update or install Java.

Check if Java is Installed

  • Open a terminal (Mac/Linux) or Command Prompt (Windows). Type java -version and press Enter.
java -version

  • If Java is installed, it will display the version number.
  • If you see an error or no version is displayed, Java is not installed, or you need an update.
Command Prompt showing the output of the 'java -version' command, displaying Java version 21.0.5 LTS installed on a Windows system.

Download the Latest Version of Java

JDK Development Kit 21.0. downloads page showing options for Linux, macOS, and Windows, with the x64 Installer download link for Windows highlighted.

Install Java

Run the downloaded installer.

  • On Windows: Double-click the installer file and follow the on-screen instructions.
  • On macOS: Open the .dmg file, drag Java into the Applications folder, and follow any prompts.
  • On Linux: Install Java using your distribution’s package manager (e.g., sudo apt install default-jdk for Ubuntu).

Complete the installation process.

Verify the Installation

  • Open Command Prompt (Windows) or Terminal (Mac/Linux).
  • Type java -version and press Enter.
  • Ensure the version displayed matches the latest version you downloaded.

If the previous steps didn’t get Java working for you, check out our article on How to Install Java 21.

Let’s begin with the setting up of the server.

Step 2: Download the Minecraft Server File

After you install or update Java on your machine, it is time to create your server. Setting up your own Minecraft server starts with downloading the official server software.

download button that redirects you to the official download page for the server.jar file

  • Click the underlined minecraft_server.jar to begin the server installation file download.
Minecraft Java Edition server download page showing the link to download the minecraft_server.1.21.4.jar file, highlighted along with the command to run the server.

Once the file has downloaded, choose a location on your computer where you want to store your Minecraft server files.

  • Create a new folder and name it something descriptive, like MinecraftServer or MyLocalServer. (The name is up to you)
  • Move the server.jar file you downloaded, into this new folder.
Minecraft Server folder showing the server.jar file, ready for use to start the Minecraft Java Edition server.

Step 3: Start the Server Installation

After downloading the server.jar file, it is time to begin the server creation.

  • Double-click the server.jar file to begin the server files extraction. If you have issues with this step double-check that your Java instance is up-to-date.

The server extraction will stop once the eula.txt file is created.

  • Open the eula.txt document with a text editor.
Minecraft Server folder displaying the eula.txt file along with server.jar and server.properties files, ready for server setup and configuration.

  • Change eula=false to eula=true and save changes.

Tip: You can read more about the EULA here.

eula.txt file open in a text editor with the eula=true line highlighted, indicating agreement to the Minecraft End User License Agreement.

  • Double-click the server.jar file again. This time all the server files will extract, and the server console will open.
Minecraft Server folder alongside the running Minecraft server console, showing server files, logs, memory usage, and startup progress in the log and chat window.

  • Close the server by typing stop into the console.
Minecraft server console with the "stop" command entered, showing how to safely shut down the server.

Move on to the next step to set up your server and have your friends join you.

Step 4: Configure Your Minecraft Server Settings

You have created your first Minecraft Java server, but you are not done yet. Right now your server is locally hosted and only you can join. It is time to configure your server properly, increase the Ram, change the settings of your world and have your friends join.

Adding more RAM

The first step in configuring your Minecraft server is increasing its RAM allocation. By default, Minecraft Java servers are set to use only 1 GB of RAM, which can lead to performance issues when multiple players join or when hosting larger worlds. Increasing the RAM ensures smoother gameplay and better server performance.

  • Open the server folder, right-click inside the folder, select New, and then click Text Document.
Minecraft Server folder with the right-click context menu open, highlighting the option to create a new text document for configuring the server.

  • Open the text document, and you’ll need to paste specific commands into your new text file to customize your server’s RAM allocation. Here’s how:
    • Copy and paste one of the following lines into your text file. These commands determine how much RAM your server will use:

Recommendation: Do not allocate more than half of your computer’s available RAM to avoid affecting system performance.

How to check my available RAM?

Windows: Press Ctrl + Shift + Esc to open Task Manager, then go to the Performance tab and look for your total RAM under Memory.

Mac: Open Activity Monitor, click the Memory tab, and check the Physical Memory section.

1 GB RAM server

java -Xmx1G -Xms1G -jar server.jar nogui  

2 GB RAM server

java -Xmx2G -Xms1G -jar server.jar nogui  

4 GB RAM server

java -Xmx4G -Xms1G -jar server.jar nogui  

8 GB RAM server

java -Xmx8G -Xms1G -jar server.jar nogui  

If you want to use more RAM than the ones above, simply replace the number in the -Xmx””G- for the amount of ram you want to use.

  • After you paste the line into the text document, make sure the server.jar in your command matches the name of the server file you downloaded (e.g., server.jar), and update the command if needed.
Minecraft Server folder highlighting the server.jar file and its reference in a new text document for setting up the server startup script.

  • Next, click File and Save As. (Ctrl+Shift+S)
Text editor menu with the "Save as" option highlighted, showing how to save the server startup script with the correct file extension.

  • Type start.bat as the File name, and select All files (*.*) for the Save as type, then click Save.
Save As dialog box with "start.bat" as the file name, "All files" as the file type, and the Save button highlighted, showing how to save the server startup script correctly.

This new start.bat file is the one we are going to be using to launch our server from now on.

Minecraft Server folder showing the newly created start.bat file, ready to be used for launching the server.

Next, let’s customize your server by editing the server.properties file to configure settings like game mode, difficulty, and player limits.

Edit the Server Properties File

The server.properties file (located inside the server folder) lets you customize key settings for your Minecraft server, such as game mode, difficulty, and player limits. Editing this file helps you tailor the server to your preferences.

  • Right-click the server.properties and open it with a text editor.
Right-click context menu for the server.properties file, with the "Edit in Notepad" option highlighted, showing how to open the file for customization.

In this document we will be able to set up our server and world settings as we like.

There are some key server settings to look at:

  1. gamemode: Set the default game mode (survival, creative, adventure, spectator). Example: gamemode=survival.
  2. difficulty: Choose game difficulty (peaceful, easy, normal, hard). Example: difficulty=normal.
  3. max-players: Limit how many players can join. Example: max-players=10.
  4. pvp: Enable or disable player vs. player combat. Example: pvp=true.
  5. motd: Add a custom message for players. Example: motd=Welcome to my server!.
  6. spawn-monsters: Toggle monster spawning. Example: spawn-monsters=true.
  7. allow-nether: Allow or block access to the Nether. Example: allow-nether=true.

Feel free to tweak these settings to customize your server and create the perfect experience for you and your friends!

Step 5: Start and Test Your Minecraft Server

  • Launch the server using the start.bat file we created earlier.

This is the new console that we are going to be using to input commands into our server.

Command Prompt running the Minecraft server with the java -Xmx8G -Xms1G -jar server.jar nogui command, showing server startup logs and successful initialization.

  • Test the server locally by connecting to it using the localhost address.
Minecraft Direct Connection screen with "localhost" entered as the server address, ready to connect to the locally hosted server.

Once you’ve confirmed that your server is running and joinable, it’s time to invite your friends! Let’s move on to the next step: Port Forwarding Your Server.

Minecraft 1.21.4 gameplay screen showing a player successfully connected to a locally hosted server in a jungle biome.

Step 6: Port Forward Your Server

Port forwarding is essential if you want players outside your local network to join your Minecraft server. This step allows your server to accept connections from other players over the internet.

To allow friends to join your Minecraft server from outside your local network, you’ll need to set up port forwarding. This process involves configuring your router to open port 25565, enabling external connections to your server.

If you’re new to port forwarding or need detailed instructions, check out our complete guide on How to Port Forward Your Minecraft Server. It covers everything you need to get your server accessible to friends!

After port-forwarding, that is it, you will be ready to have your friends join you in no time.

Conclusion

Congratulations! By following this guide, you’ve successfully set up your very own Minecraft Java Edition server. Whether you’re playing with friends, customizing your world, or hosting a unique gaming experience, your server is now ready for action. As you explore, don’t hesitate to tweak your settings, experiment with mods or plugins, and make your server truly your own.

If you want to make your server accessible to friends online, remember to follow our Port Forwarding Guide.

Troubleshooting

Server Won’t Start

  • Ensure you’ve accepted the EULA in eula.txt.
  • Check that your start.bat file references the correct server.jar filename.

Can’t Connect to Server

  • Make sure the server is running and you’re connecting to localhost for local testing.
  • For external connections, confirm that port forwarding is configured correctly.

Lag or Performance Issues

  • Allocate more RAM to the server in your start.bat file.
  • Reduce view-distance in the server.properties file to lower the load on your server.

Minecraft Java Server FAQs

How do I connect to my server locally?
Use localhost as the server address when connecting from the same computer or device hosting the server.

Why isn’t my server running smoothly?
Performance issues may be caused by insufficient RAM. Make sure to allocate more RAM in your start.bat file and lower settings like view-distance in the server.properties file.

How do I customize my server settings?
Edit the server.properties file to adjust settings like game mode, difficulty, player limit, and more. Save the file and restart the server for changes to take effect.

What’s the difference between the gamemode settings?

  • survival: Standard gameplay with health and hunger.
  • creative: Unlimited resources and flying mode.
  • adventure: Designed for custom maps with interaction limits.
  • spectator: Observe the world without interacting.

Can I install mods or plugins on my server?
Yes, but you’ll need to use a mod-compatible server type like Forge for mods or Spigot/Bukkit for plugins.