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.mdCreating the Dockerfile
Create a Dockerfile for your OpenTTD server:
FROM bateau/openttd:latest
# Set environment variablesENV PUID=1000ENV PGID=1000
# Server name visible in server browserENV SERVER_NAME="Klutch.sh OpenTTD Server"
# Create directories for custom contentRUN mkdir -p /home/openttd/.openttd/content_download/newgrfRUN mkdir -p /home/openttd/.openttd/saveRUN mkdir -p /home/openttd/.openttd/scenario
# Copy custom configuration if providedCOPY openttd.cfg /home/openttd/.openttd/openttd.cfg
# Expose the game portEXPOSE 3979/tcpEXPOSE 3979/udp
# Admin port for remote managementEXPOSE 3977/tcpCreating the Configuration File
Create an openttd.cfg file with your server settings:
[network]server_name = Klutch.sh OpenTTD Serverserver_password =server_advertise = truelan_internet = 0max_clients = 25max_companies = 15max_spectators = 10autoclean_companies = trueautoclean_unprotected = 12autoclean_protected = 36
[gui]autosave = monthlyfast_forward_speed_limit = 2500
[game_creation]map_x = 9map_y = 9landscape = temperatestarting_year = 1950ending_year = 2050snow_line_height = 10number_towns = 2number_industries = 2terrain_type = 1
[difficulty]competitor_speed = 2number_towns = 2industry_density = 4max_loan = 500000initial_interest = 2vehicle_costs = 0competitor_intelligence = 1
[script]settings_profile = easyEnvironment Variables Reference
| Variable | Default | Description |
|---|---|---|
SERVER_NAME | OpenTTD Server | Name displayed in server browser |
SERVER_PASSWORD | - | Password required to join (empty = public) |
PUID | 1000 | User ID for file permissions |
PGID | 1000 | Group ID for file permissions |
Deploying OpenTTD on Klutch.sh
Follow these steps to deploy your OpenTTD server:
server_name: Your server’s display namemax_clients: Maximum number of connected playersserver_advertise: Whether to list on the public server browser- Map size and generation settings
- Configure traffic for port 3979 (both TCP and UDP)
- Optionally expose port 3977 for admin access
- Go to Multiplayer > Add Server
- Enter your Klutch.sh URL and port (e.g.,
your-app-name.klutch.sh:3979) - Click Connect to join the game
Prepare Your Configuration
Customize the openttd.cfg file with your preferred server settings. Key settings to consider:
Push Your Repository to GitHub
Initialize and push your repository:
git initgit add Dockerfile openttd.cfg .dockerignore README.mdgit commit -m "Initial OpenTTD server configuration"git remote add origin https://github.com/yourusername/openttd-server.gitgit push -u origin mainCreate 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:
Set Environment Variables
Configure your server settings:
| Variable | Value |
|---|---|
SERVER_NAME | Your server name |
SERVER_PASSWORD | Optional password for private games |
PUID | 1000 |
PGID | 1000 |
Attach Persistent Volumes
Add persistent storage for game data:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/home/openttd/.openttd/save | 5 GB | Save game files |
/home/openttd/.openttd/content_download | 2 GB | Downloaded content (NewGRFs, AIs) |
/home/openttd/.openttd/scenario | 1 GB | Custom 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:
Server Administration
In-Game Console Commands
Access the console by pressing the tilde (~) key in-game:
# Kick a playerkick <client-id>
# Ban a playerban <client-id>
# Set server passwordserver_pw <password>
# Pause the gamepause
# Unpause the gameunpause
# Save the gamesave <filename>
# Load a save gameload <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:
- Set an admin password in configuration
- Use compatible admin tools to connect
- Monitor players, manage companies, and control the game
Custom Content
Adding NewGRFs
NewGRFs modify game graphics, vehicles, and mechanics:
- Download NewGRF files from BaNaNaS
- Upload to
/home/openttd/.openttd/content_download/newgrf - Configure NewGRFs in
openttd.cfgor via in-game content system
Loading Custom Scenarios
Use custom-designed maps:
- Upload scenario files to
/home/openttd/.openttd/scenario - Use the console to load:
load scenario/<filename>
AI Opponents
Add computer competitors:
- Download AI scripts from BaNaNaS
- Configure AI count and difficulty in settings
- AIs will automatically start new companies
Game Configuration Tips
Map Size Recommendations
| Players | Recommended Size | Setting |
|---|---|---|
| 1-5 | 512x512 | map_x=9, map_y=9 |
| 5-15 | 1024x1024 | map_x=10, map_y=10 |
| 15-25 | 2048x1024 | map_x=11, map_y=10 |
| 25+ | 2048x2048 | map_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
- OpenTTD Official Website
- OpenTTD Wiki
- BaNaNaS Content Service
- OpenTTD GitHub Repository
- Dedicated Server Guide
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
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.