Skip to content

Deploying OpenTTD

Introduction

OpenTTD is an open-source transport simulation game based on the classic Transport Tycoon Deluxe. Players build and manage transport networks spanning rail, road, sea, and air to connect industries and towns while competing or cooperating with other players. The game features extensive modding support, AI opponents, and dedicated server capabilities for persistent multiplayer worlds.

Originally released in 2004, OpenTTD has evolved into a feature-rich simulation with modern graphics sets, improved gameplay mechanics, and robust multiplayer support. The dedicated server mode allows hosting always-on game worlds where players can join, build their transport empires, and compete on shared maps.

Key highlights of OpenTTD:

  • Multiplayer Support: Host games for up to 255 players with dedicated server mode
  • Persistent Worlds: Games continue running even when players disconnect
  • Custom Content: Support for NewGRFs, AIs, game scripts, and scenario files
  • Multiple Transports: Build rail, road, air, and sea transport networks
  • Economic Simulation: Manage finances, loans, and company growth
  • Industry Chains: Connect producers to consumers across complex supply chains
  • Custom Maps: Generate random maps or load custom scenarios
  • Spectator Mode: Allow viewers to watch games without participating
  • Admin Port: Remote administration and integration with external tools
  • Autosave: Automatic game saves prevent progress loss

This guide walks through deploying an OpenTTD dedicated server on Klutch.sh using Docker, configuring multiplayer settings, and managing your game world.

Why Deploy OpenTTD on Klutch.sh

Deploying OpenTTD on Klutch.sh provides several advantages for hosting your game server:

Simplified Deployment: Klutch.sh automatically builds and deploys your game server. Push to GitHub, and your server deploys without manual intervention.

Persistent Storage: Attach persistent volumes for save games, configuration, and custom content. Your game world survives container restarts and updates.

Always-On Gaming: Unlike home-hosted servers, your OpenTTD world runs 24/7 with reliable uptime, allowing players to join whenever they want.

GitHub Integration: Store your server configuration in Git. Update settings by pushing changes to your repository.

Scalable Resources: Allocate CPU and memory based on player count and map size. Scale resources for larger games.

Custom Domains: Assign a memorable domain name for your game server instead of using IP addresses.

Automatic Reconnection: Players can reconnect to the same address after server updates without reconfiguring their client.

Prerequisites

Before deploying OpenTTD on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your OpenTTD configuration
  • Basic familiarity with Docker and containerization concepts
  • OpenTTD game client for testing and playing
  • (Optional) Custom NewGRFs or scenarios you want to use

Understanding OpenTTD Server Architecture

An OpenTTD dedicated server consists of:

Game Engine: The core OpenTTD binary running in headless mode without graphics, processing game logic and physics.

Network Layer: Handles player connections, synchronization, and game state distribution across all connected clients.

Content System: Manages NewGRFs (graphics/gameplay mods), AI scripts, game scripts, and custom scenarios.

Configuration Files: openttd.cfg and related files control server behavior, game rules, and network settings.

Save System: Automatically saves game progress at configurable intervals and on shutdown.

Preparing Your Repository

Create a GitHub repository containing your Dockerfile and server configuration.

Repository Structure

openttd-server/
├── Dockerfile
├── .dockerignore
├── openttd.cfg
└── README.md

Creating the Dockerfile

Create a Dockerfile for your OpenTTD server:

FROM bateau/openttd:latest
# Set environment variables
ENV PUID=1000
ENV PGID=1000
# Server name visible in server browser
ENV SERVER_NAME="Klutch.sh OpenTTD Server"
# Create directories for custom content
RUN mkdir -p /home/openttd/.openttd/content_download/newgrf
RUN mkdir -p /home/openttd/.openttd/save
RUN mkdir -p /home/openttd/.openttd/scenario
# Copy custom configuration if provided
COPY openttd.cfg /home/openttd/.openttd/openttd.cfg
# Expose the game port
EXPOSE 3979/tcp
EXPOSE 3979/udp
# Admin port for remote management
EXPOSE 3977/tcp

Creating the Configuration File

Create an openttd.cfg file with your server settings:

[network]
server_name = Klutch.sh OpenTTD Server
server_password =
server_advertise = true
lan_internet = 0
max_clients = 25
max_companies = 15
max_spectators = 10
autoclean_companies = true
autoclean_unprotected = 12
autoclean_protected = 36
[gui]
autosave = monthly
fast_forward_speed_limit = 2500
[game_creation]
map_x = 9
map_y = 9
landscape = temperate
starting_year = 1950
ending_year = 2050
snow_line_height = 10
number_towns = 2
number_industries = 2
terrain_type = 1
[difficulty]
competitor_speed = 2
number_towns = 2
industry_density = 4
max_loan = 500000
initial_interest = 2
vehicle_costs = 0
competitor_intelligence = 1
[script]
settings_profile = easy

Environment Variables Reference

VariableDefaultDescription
SERVER_NAMEOpenTTD ServerName displayed in server browser
SERVER_PASSWORD-Password required to join (empty = public)
PUID1000User ID for file permissions
PGID1000Group ID for file permissions

Deploying OpenTTD on Klutch.sh

Follow these steps to deploy your OpenTTD server:

    Prepare Your Configuration

    Customize the openttd.cfg file with your preferred server settings. Key settings to consider:

    • server_name: Your server’s display name
    • max_clients: Maximum number of connected players
    • server_advertise: Whether to list on the public server browser
    • Map size and generation settings

    Push Your Repository to GitHub

    Initialize and push your repository:

    Terminal window
    git init
    git add Dockerfile openttd.cfg .dockerignore README.md
    git commit -m "Initial OpenTTD server configuration"
    git remote add origin https://github.com/yourusername/openttd-server.git
    git push -u origin main

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project named “openttd” or “transport-tycoon”.

    Create a New App

    Within your project, create a new app. Connect your GitHub account and select the repository containing your OpenTTD Dockerfile.

    Configure Network Traffic

    OpenTTD uses TCP and UDP on port 3979. In the deployment settings:

    • Configure traffic for port 3979 (both TCP and UDP)
    • Optionally expose port 3977 for admin access

    Set Environment Variables

    Configure your server settings:

    VariableValue
    SERVER_NAMEYour server name
    SERVER_PASSWORDOptional password for private games
    PUID1000
    PGID1000

    Attach Persistent Volumes

    Add persistent storage for game data:

    Mount PathRecommended SizePurpose
    /home/openttd/.openttd/save5 GBSave game files
    /home/openttd/.openttd/content_download2 GBDownloaded content (NewGRFs, AIs)
    /home/openttd/.openttd/scenario1 GBCustom scenario files

    Deploy Your Application

    Click Deploy to start the build process. Once complete, your server will start a new game or load an existing save.

    Connect to Your Server

    Open your OpenTTD client:

    1. Go to Multiplayer > Add Server
    2. Enter your Klutch.sh URL and port (e.g., your-app-name.klutch.sh:3979)
    3. Click Connect to join the game

Server Administration

In-Game Console Commands

Access the console by pressing the tilde (~) key in-game:

# Kick a player
kick <client-id>
# Ban a player
ban <client-id>
# Set server password
server_pw <password>
# Pause the game
pause
# Unpause the game
unpause
# Save the game
save <filename>
# Load a save game
load <filename>

Managing Companies

Configure company management in your settings:

  • Autoclean: Automatically remove inactive companies
  • Protected Time: How long password-protected companies stay
  • Unprotected Time: How long unprotected companies remain

Remote Administration

The admin port (3977) allows external tools to manage your server:

  1. Set an admin password in configuration
  2. Use compatible admin tools to connect
  3. Monitor players, manage companies, and control the game

Custom Content

Adding NewGRFs

NewGRFs modify game graphics, vehicles, and mechanics:

  1. Download NewGRF files from BaNaNaS
  2. Upload to /home/openttd/.openttd/content_download/newgrf
  3. Configure NewGRFs in openttd.cfg or via in-game content system

Loading Custom Scenarios

Use custom-designed maps:

  1. Upload scenario files to /home/openttd/.openttd/scenario
  2. Use the console to load: load scenario/<filename>

AI Opponents

Add computer competitors:

  1. Download AI scripts from BaNaNaS
  2. Configure AI count and difficulty in settings
  3. AIs will automatically start new companies

Game Configuration Tips

Map Size Recommendations

PlayersRecommended SizeSetting
1-5512x512map_x=9, map_y=9
5-151024x1024map_x=10, map_y=10
15-252048x1024map_x=11, map_y=10
25+2048x2048map_x=11, map_y=11

Performance Settings

For smooth multiplayer performance:

  • Enable autosave to prevent data loss
  • Set reasonable speed limits for fast-forward
  • Limit maximum concurrent companies
  • Configure appropriate autoclean timeouts

Troubleshooting Common Issues

Players Cannot Connect

Symptoms: Connection timeouts or failures.

Solutions:

  • Verify the server is running in deployment logs
  • Check port configuration (TCP and UDP 3979)
  • Ensure no firewall is blocking connections
  • Verify the correct server address

Game Desyncs

Symptoms: Players disconnected with desync errors.

Solutions:

  • Ensure all players have matching NewGRFs
  • Update to the latest OpenTTD version
  • Reduce game speed during heavy activity
  • Check server logs for specific desync causes

Save Game Not Loading

Symptoms: Server starts with new game instead of save.

Solutions:

  • Verify save file exists in correct location
  • Check file permissions on save directory
  • Ensure save file is not corrupted
  • Check logs for load errors

Missing Content

Symptoms: NewGRFs or AIs not available.

Solutions:

  • Verify content files are in correct directories
  • Check file permissions
  • Restart server after adding content
  • Use BaNaNaS to download missing content

Additional Resources

Conclusion

Deploying OpenTTD on Klutch.sh provides a reliable, always-on game server for your transport simulation adventures. With persistent storage for save games and custom content, your game world continues growing even when you are not playing.

The combination of OpenTTD’s extensive customization options and Klutch.sh’s simplified deployment means you can focus on building your transport empire rather than managing server infrastructure. Whether hosting a public server for the community or a private game for friends, your OpenTTD server on Klutch.sh delivers consistent, accessible multiplayer gaming.

Invite your friends, start laying tracks, and watch your transport network grow across the map. With automatic saves and persistent storage, your progress is always protected.