Modded Minecraft Server (Forge) with Twingate (Linux)

Host a private Forge modded Minecraft server on bare-metal Linux without Docker.


Overview

A modded Minecraft server adds extra setup on top of a vanilla server. The server needs Forge installed, mods loaded, and enough RAM to run them. Every player connecting must have the same mods (and same versions) installed on their client, or the server will reject the connection.

The Docker version of this guide includes automated CurseForge modpack installation, which downloads and configures mods automatically from a single URL. That feature is specific to the Docker image. This guide covers native Linux installation, where you install Forge and add mods manually. If you want CurseForge auto-install, use the Docker guide instead.

The Twingate setup is identical to a vanilla server. You install a native Twingate Connector on the Linux host alongside the Forge server, and players connect using the server’s private IP address through the Twingate Client.

Architecture

[Player's Device]
↓ Twingate Client
[Twingate Cloud]
[Twingate Connector]
[Forge Server — port 25565]

Prerequisites

  • A Linux machine (physical or virtual) with at least 4 GB of RAM, 2 CPU cores, and 20 GB of free disk space. Ubuntu 22.04, Ubuntu 24.04, and Debian 12 are tested.
  • Java 17 (for Minecraft 1.20.x) or Java 21 (for Minecraft 1.21 and later) installed on the server.
  • A Twingate account with access to the Admin Console. Sign up for free if you do not have one.
  • SSH or terminal access to the Linux machine.

Step 1: Create a Remote Network and Generate Connector Tokens

Follow Step 1 in the vanilla Minecraft guide to create a Remote Network and generate Connector tokens, then return here.


Step 2: Install and Configure the Forge Server

This section covers native Forge installation on Linux. If you want automated CurseForge modpack installation instead, use the Docker guide.

Create the Server User and Directory

  • SSH into the Linux machine.
  • Create a dedicated system user for the Minecraft server:
sudo useradd -r -m -d /opt/minecraft-forge -s /bin/bash minecraft
  • Create the server directory:
sudo mkdir -p /opt/minecraft-forge/server
sudo chown -R minecraft:minecraft /opt/minecraft-forge

Install Java

  • Install Java 17 (for Minecraft 1.20.x):
sudo apt update
sudo apt install -y openjdk-17-jre-headless

For Minecraft 1.21 and later, install Java 21 instead:

sudo apt update
sudo apt install -y openjdk-21-jre-headless
  • Verify the Java version:
java -version

Download and Install Forge

  • Visit files.minecraftforge.net to find the Forge version that matches your Minecraft version and mods. Copy the Installer download link.

  • Download and run the Forge installer:

sudo -u minecraft bash -c 'cd /opt/minecraft-forge/server && \
curl -O "https://maven.minecraftforge.net/net/minecraftforge/forge/1.20.1-47.2.0/forge-1.20.1-47.2.0-installer.jar" && \
java -jar forge-1.20.1-47.2.0-installer.jar --installServer && \
rm forge-1.20.1-47.2.0-installer.jar'

The installer downloads Forge, Minecraft, and required libraries. This takes 1-2 minutes.

Accept the EULA

  • Create the eula.txt file and accept the Minecraft End User License Agreement:
sudo -u minecraft bash -c 'echo "eula=true" > /opt/minecraft-forge/server/eula.txt'

Add Mods

  • Create the mods directory:
sudo -u minecraft mkdir -p /opt/minecraft-forge/server/mods
  • Copy your mod .jar files to the server. From your local machine, use scp or rsync:
scp /path/to/your/mods/*.jar user@your-server:/tmp/
  • Move the mods into the server directory:
sudo mv /tmp/*.jar /opt/minecraft-forge/server/mods/
sudo chown -R minecraft:minecraft /opt/minecraft-forge/server/mods

Configure Server Settings

  • The Forge installer creates a server.properties file on first launch. You can pre-configure it now, or let it generate with defaults and edit it later. For now, create a basic configuration:
sudo -u minecraft bash -c 'cat > /opt/minecraft-forge/server/server.properties << EOF
server-port=25565
max-players=10
difficulty=normal
gamemode=survival
motd=Private Forge Server
online-mode=true
EOF'

Set Memory Allocation

  • The Forge installer creates a user_jvm_args.txt file that controls Java memory settings. Edit it to set memory allocation:
sudo -u minecraft bash -c 'echo "-Xmx4G -Xms2G" > /opt/minecraft-forge/server/user_jvm_args.txt'

For large modpacks, increase -Xmx to 6G or 8G.

Make the Startup Script Executable

  • The Forge installer creates run.sh, but it may not be executable. Fix permissions:
sudo chmod +x /opt/minecraft-forge/server/run.sh

Create a Systemd Service

  • Create a systemd service file to manage the Forge server:
sudo tee /etc/systemd/system/minecraft-forge.service > /dev/null << 'EOF'
[Unit]
Description=Minecraft Forge Modded Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft-forge/server
ExecStart=/opt/minecraft-forge/server/run.sh --nogui
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=minecraft-forge
[Install]
WantedBy=multi-user.target
EOF

Start the Forge Server

  • Reload systemd, enable the service, and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft-forge
  • Watch the logs to verify startup:
sudo journalctl -u minecraft-forge -f

Wait until you see a line containing For help, type "help" (the full line reads Done (15.0s)! For help, type "help"). This confirms the server finished loading. Press Ctrl+C to exit the log view.

Install the Twingate Connector

  • Install the native Twingate Connector on the same host. Replace the placeholder values with your tokens from Step 1:
curl "https://binaries.twingate.com/connector/setup.sh" | \
sudo TWINGATE_ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>" \
TWINGATE_REFRESH_TOKEN="<YOUR_REFRESH_TOKEN>" \
TWINGATE_NETWORK="<YOUR_TWINGATE_NETWORK>" \
bash
  • Verify the Connector is running:
sudo systemctl status twingate-connector

The status should show active (running).

Verify the Connector in Admin Console

  • In the Twingate Admin Console, navigate to Remote Networks and select your network.
  • Click on the Connector. Verify that the Controller and Relay statuses both show Connected.

Step 3: Add the Forge Server as a Resource

The Resource configuration is the same as a vanilla server: TCP port 25565.

Find Your Server’s Private IP Address

  • On the Linux machine, run:
hostname -I | awk '{print $1}'

Note the IP address (e.g., 192.168.1.50).

Create the Resource

  • In the Twingate Admin Console, navigate to Resources and click Add Resource.
  • Select the Remote Network from Step 1.
  • Configure the Resource:
    • Name: Forge Server
    • Address: Your server’s private IP address (e.g., 192.168.1.50)
    • Protocols: TCP port 25565
  • Click Create Resource.

Assign Access

  • Select the Group that contains your players (the default Everyone Group works for getting started) and click Grant Access.

Step 4: Connect Players

Modded Minecraft has an extra step compared to vanilla: every player needs the same mods installed on their client. The server will refuse connections from clients with missing or mismatched mods.

Install the Twingate Client

Each player installs the Twingate Client:

Then sign in with the Twingate Network address (e.g., yournetwork.twingate.com) and the account the server admin invited you with.

Install the Mods

Players need to install the same mods the server is running. There are two ways to do this:

Option A: Manual Mod Installation

  • Download and run the Forge installer for the same Minecraft version the server is running.
  • Select Install client and click OK.
  • Get the same mod .jar files the server uses. The server admin can share them, or you can download them from CurseForge or Modrinth.
  • Copy the mod files into your client’s mods/ folder:
    • Windows: %appdata%\.minecraft\mods\
    • macOS: ~/Library/Application Support/minecraft/mods/
    • Linux: ~/.minecraft/mods/
  • In the Minecraft Launcher, select the Forge profile and launch.

Option B: CurseForge Modpack Launcher

If the server admin assembled the mods as a CurseForge modpack:

  • Install a mod launcher: CurseForge App, Prism Launcher, or ATLauncher.
  • Search for the modpack name the server admin gave you.
  • Install it. The launcher downloads Forge and all the mods automatically.

Add the Server in Minecraft

  • In the modded Minecraft instance, click Multiplayer, then Add Server.
  • Enter the server’s private IP address (e.g., 192.168.1.50).
  • Click Done, then select the server and click Join Server.

Step 5: Manage Player Access

Access management works the same way as a vanilla server. Create a Twingate Group, add your players, and assign the Group to the Forge Server Resource. See Step 5 in the vanilla guide for the full walkthrough.


Customizing the Server

Server Properties

Edit /opt/minecraft-forge/server/server.properties to change server behavior:

PropertyDefaultDescription
server-port25565Port the server listens on
max-players20Maximum concurrent players
difficultynormalpeaceful, easy, normal, hard
gamemodesurvivalDefault game mode: survival, creative, adventure, spectator
motd(none)Message shown in the server browser
online-modetrueRequire authenticated Minecraft accounts
view-distance10Render distance in chunks (lower reduces RAM usage)

After changing server.properties, restart the server:

sudo systemctl restart minecraft-forge

Memory Allocation

Edit /opt/minecraft-forge/server/user_jvm_args.txt to change memory settings:

-Xmx6G -Xms3G

Then restart: sudo systemctl restart minecraft-forge.

Mod Configuration

Most mods create configuration files in /opt/minecraft-forge/server/config/. Each mod’s config is different. Check the mod’s documentation for details. After changing mod configs, restart the server.

Adding or Removing Mods

To add a new mod:

  • Copy the .jar file to /opt/minecraft-forge/server/mods/.
  • Restart the server: sudo systemctl restart minecraft-forge.
  • Give the same mod to all players.

To remove a mod:

  • Delete its .jar file from /opt/minecraft-forge/server/mods/.
  • Restart the server.
  • Have players remove the mod from their client mods/ folder.

Troubleshooting

“Mod Rejections” When Connecting

The server lists which mods are missing or have wrong versions. Compare the server’s mod list (/opt/minecraft-forge/server/mods/) with the player’s client mods/ folder. Both sides need the same files.

To see which mods the server has:

ls -1 /opt/minecraft-forge/server/mods/

Ask the player to check their client’s mods/ folder and verify the filenames match exactly.

Server Crashes on Startup

  • Check the logs: sudo journalctl -u minecraft-forge -n 200. The most useful file is also /opt/minecraft-forge/server/logs/latest.log.
  • Look for java.lang.OutOfMemoryError. If you see it, increase the -Xmx value in user_jvm_args.txt. Large modpacks need 6-8 GB.
  • Look for mod conflict errors. Two mods that modify the same game mechanic can crash the server. Try removing the most recently added mod and restarting.
  • Check Java version: java -version. Minecraft 1.20.x requires Java 17. Minecraft 1.21+ requires Java 21.

Server Takes a Long Time to Start

This is normal. Forge loads every mod at startup, and large modpacks (200+ mods) can take 3-5 minutes. First-time startup is even slower because it generates the world.

If it takes more than 10 minutes, check the logs for errors: sudo journalctl -u minecraft-forge -f. A mod that hangs during initialization will stall the whole startup.

Permission Errors

If the server fails to start with permission errors:

sudo chown -R minecraft:minecraft /opt/minecraft-forge
sudo chmod +x /opt/minecraft-forge/server/run.sh
sudo systemctl restart minecraft-forge

Wrong Java Version

If the logs show Unsupported class file major version or similar:

  • Check which Java version you have: java -version.
  • Minecraft 1.20.x needs Java 17. Minecraft 1.21+ needs Java 21.
  • Install the correct version (see Step 2) and restart the server.

Server Not Starting (run.sh Not Executable)

If the server fails silently:

sudo chmod +x /opt/minecraft-forge/server/run.sh
sudo systemctl restart minecraft-forge

Connector Shows Offline in Admin Console

  • Are the TWINGATE_ACCESS_TOKEN, TWINGATE_REFRESH_TOKEN, and TWINGATE_NETWORK values correct?
  • Does the host machine have outbound internet access? The Connector needs to reach Twingate Cloud.
  • Check the Connector logs: sudo journalctl -u twingate-connector -f.

Next Steps

  • Vanilla Minecraft guide: Running an unmodded server alongside your Forge server.
  • Bedrock Edition guide: Hosting Bedrock for mobile and Windows players.
  • Forge Docker guide: Automated CurseForge modpack installation using Docker.
  • Resources: Learn more about configuring Twingate Resources, including wildcard DNS and CIDR-based Resources.
  • Security Policies: Add multi-factor authentication or device trust requirements for players connecting to your server.
  • Protect Your Home Lab: Extend Twingate to secure other services running on your home network.

Last updated 6 days ago