How to set up a private Factorio server with Meshnet

Learn how Meshnet can help you run a personal Factorio server.

Introduction

Factorio is a highly acclaimed simulation game that has gained widespread popularity due to its engaging mechanics, where players scavenge resources and build factories to escape an alien planet. With its sandbox-style gameplay and creative freedom, it's no wonder Factorio consistently ranks among the most popular games.

Factorio can be enjoyed as a single-player or multiplayer experience. Building and managing factories with friends can lead to unforgettable moments. However, setting up and maintaining your own Factorio server can seem overwhelming.

With the help of Meshnet, the process becomes much easier. Meshnet allows you to seamlessly connect various devices from different locations into a single virtual device network, as if they were physically on the same local area network (LAN). This eliminates the need for port forwarding and keeps your home network secure. Meshnet connects each device via encrypted network tunnels using the NordLynx protocol, ensuring the best combination of speed and security.

This guide provides step-by-step guidance on how you set up a private Factorio server on Windows, macOS, or Linux allowing you and your friends to enjoy the game together from anywhere in the world using Meshnet.

Configure your Factorio server

Several options are available for creating and running your own Factorio server, allowing you to choose the method that best suits your needs and preferences.

Method 1: Using in-game options

To get started quickly, you can launch your server with just a few clicks directly from the game.

  1. Launch Factorio.

  2. Select Multiplayer > Host new game.

  3. Choose your game type and click Next.

    "Freeplay" game mode selected and clicking the "Next" button.

  4. If your selected game mode requires it, configure your map settings and click Next again.

  5. In the Multiplayer server settings window, make the following changes:

    • In the Server name field, enter a custom name for your server.

    • In the Server password field, type in a secure password that other players must enter to join.

    • Under Visibility, ensure that only the LAN server visibility option is selected. Example

      Filled in server and and password fields, and the LAN option selected.

  6. Click Play.

Once you’re loaded into the map, you can invite others to join your server. See the Connect to your Factorio server over Meshnet section for further details.

Method 2: Using a Factorio dedicated server

The Factorio executable supports command-line interaction, enabling you to run the server with minimal resource usage, as no graphics or audio are loaded on the server machine. Follow the steps below to deploy your server using Factorio in headless mode.

Note

Running a headless Factorio instance on Windows will prevent you from opening the game on the same computer.

Prepare the server settings file

Factorio server details, including settings and map preferences, are stored in multiple JavaScript Object Notation (JSON) files. These files serve as the backend for the Multiplayer server settings window accessible within the game. To get started, you’ll need to back up and modify the server settings file.

  1. Open File explorer and navigate to the Factorio installation directory.

  2. Open the data folder.

  3. Create a copy of the server-settings.example.json file and name it server-settings.json.

  4. Open the new server-settings.json file using a text editor, such as Notepad.

  5. Make the following changes to the JSON file:

    • Next to the "name" and "description" fields, change the string values to identify and describe your server. Example

      "name" and "description" field values updated.

    • Under "visibility", change the "public" field value to false.

      "public" field value set to false.

    • Next to the "game_password" field, type in a secure password that other players must enter to join. Example

      Password highlighted in the "game_password" field value.

  6. Save your changes and close the text editor.

Start the server

  1. Open PowerShell.

  2. Using the cd command, navigate to the Factorio installation directory.

    Example

    cd "C:\Program Files\Steam\steamapps\common\Factorio"

  3. Run the following command to create a new save file, where the server will store its progress.

    .\bin\x64\factorio.exe --create .\saves\savefile.zip

  4. Use the command below to initialize your server with the newly created save file and the previously configured settings file:

    .\bin\x64\factorio.exe --start-server .\saves\savefile.zip --server-settings .\data\server-settings.json

    If the server is started successfully, the last few lines in PowerShell should read similar to the following:

    PowerShell output indicating that the server has started successfully.

Your server is active and ready for other players to join. For further instructions, see the Connect to your Factorio server over Meshnet section below.

Note

Detailed descriptions of the command-line parameters and additional options are available on the Factorio wiki page.

(Optional) Automate server launch

To streamline the process of starting your Factorio server, you can create a batch file. This method saves time by eliminating the need to manually enter lengthy commands into the command line each time. Simply run the script file, and it will automatically handle the server launch for you.

Take the following steps to create your server launch script file:

  1. Open a text editor, such as Notepad.

  2. Add the following lines to the file, replacing the placeholder <\path\to\Factorio> with the path to the Factorio installation directory.

    @echo off
    
    title Start your Factorio server
    
    echo Starting server... 
    cd /d "<\path\to\Factorio>" 
    start /wait "" .\bin\x64\factorio --start-server .\saves\savefile.zip --server-settings .\data\server-settings.json
    
    pause

    Example

    Batch file content with path to the Factorio folder.

  3. Click File > Save As.

  4. From the Save as type list, select All files, and use a file name with a .bat extension. For example, factorio-server.bat.

    File name and type highlighted.

  5. Choose a convenient location where the file should be saved, such as Desktop, and click Save.

Now, when you want to start your server, open the .bat file and the following sequence of actions will take place:

  1. A Command Prompt window will open.

  2. The Factorio executable will launch using the specified save and settings files.

  3. The server will initialize and start running.

Method 3: Using Docker

The third alternative for running your server is deploying it via Docker. This approach is the most efficient, as it minimizes system resource usage by running the server in a lightweight container, eliminating the need to install the game directly on the server.

Install Docker

To use this method, you must have Docker and Docker Compose installed on your device. Instructions on how to download and install these tools can be found on the Docker website:

Note

Docker Compose comes pre-installed with Docker Desktop.

Prepare the Docker Compose file

Firstly, you must define the instructions for the Factorio server container in the Docker Compose file.

  1. Open PowerShell.

  2. In your preferred location, create a new factorio_server folder and navigate to it using the following command:

    mkdir factorio_server; cd factorio_serve

  3. Create a docker-compose.yml file and open it using Notepad by running:

    notepad docker-compose.yml

    When prompted to create the file, click Yes.

  4. In Notepad, paste the following instructions for the Factorio server Docker container:

    services:
      factorio:
        container_name: factorio-server
        image: factoriotools/factorio:stable-2.0.23
        ports:
          - "34197:34197/udp"
          - "27015:27015/tcp"
        volumes:
         - .\factorio:/factorio
        environment:
         - DLC_SPACE_AGE=false

  5. Ensure that the version declared in the image: row matches the version of your game. If required, modify the version accordingly. For more information about versioning, see the Readme file of the factoriotools/factorio-docker GitHub repository.

  6. Press Ctrl + S to save changes.

  7. Exit Notepad.

Note

If all players connecting to the server own the Space Age expansion pack and you wish to enable it for the server, set the DLC_SPACE_AGE value to true in the Compose file.

Deploy the Factorio server

Lastly, you can create and deploy your Factorio server by using the data declared in the Compose file. While in the factorio_server directory, run the following command:

docker compose up -d

Docker will pull the Factorio server image from Docker Hub and deploy the container. Once the container is up and running, you can connect to the server, as described in the section below.

Connect to your Factorio server over Meshnet

Note

If you're hosting the Factorio server using Docker on a Linux device, you must grant the local network permission for the devices connecting to it. For more information, see Common issues on Linux.

Once the Factorio server is up and running, you and your friends can connect to it for a collaborative gaming experience.

  1. Copy the Meshnet IP address of the device hosting the Factorio server from the NordVPN app.

    Copying the Meshnet IP address from the NordVPN app.

  2. Launch Factorio.

  3. Select Multiplayer > Connect to address.

  4. In the IP address and port field, paste the copied Meshnet IP address and click Connect. Example

    Entering the Meshnet IP address of the Factorio server and clicking "Connect".

  5. If required, enter the server’s password.

Within a few moments, you should be connected to the server and you can begin your factory-building journey.

Two players loaded into the Factorio server.

Last updated

Was this helpful?