Skip to content

Commit e9432f2

Browse files
authored
Merge pull request #156 from HiSch/patch-1
Create factorio_headless_server_on_proxmox_lxc.md
2 parents 7e431ad + abc542d commit e9432f2

File tree

1 file changed

+288
-0
lines changed

1 file changed

+288
-0
lines changed
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# Factorio Headless Server on Proxmox (LXC)
2+
3+
*Guest contribution by [HiSch](https://github.com/HiSch)*
4+
5+
This guide will walk you through creating a Proxmox LXC container and setting up a **Factorio headless server** inside it.
6+
7+
8+
***
9+
10+
## 1. Create a New Proxmox LXC Container
11+
12+
1. **Download a CT template**
13+
- In Proxmox, select your **host** → go to **local (hostname)** → click **CT Templates**.
14+
- Click **Templates** and download one.
15+
- For this guide, we’ll use:
16+
**`debian-12`**
17+
2. **Create a new container**
18+
- Right-click your Proxmox host → **Create CT**.
19+
- **Hostname**: choose a name (e.g. `factorio`).
20+
- **Password**: set root password. → **Next**
21+
3. **Storage \& Template**
22+
- Pick your storage.
23+
- Select the `debian-12` CT template. → **Next**
24+
4. **Disk Size**
25+
- Recommended: `20 GB`.
26+
5. **CPU**
27+
- 2 Cores should be fine (unless you expect very heavy loads).
28+
6. **Memory**
29+
- `4096 MB RAM` + `4096 MB Swap` is a good start.
30+
- You can always change later in Proxmox.
31+
7. **Network**
32+
- Enable DHCP (default works for most setups).
33+
- Advanced users can configure a custom network.
34+
8. **DNS Settings**
35+
- Default is fine.
36+
9. **Finish**
37+
- Click **Finish** → wait for container creation.
38+
39+
***
40+
41+
## 2. Initial Container Setup
42+
43+
1. Click your new **LXC container****Console/Shell**.
44+
2. Log in as `root` (default).
45+
3. Update and install required dependencies:
46+
47+
```bash
48+
apt update
49+
apt install wget tar rsync -y
50+
```
51+
52+
4. Create a new user for Factorio:
53+
54+
```bash
55+
adduser factorio
56+
```
57+
58+
Set a password when prompted.
59+
60+
***
61+
62+
## 3. Install Factorio Headless
63+
64+
1. Log in as the new user:
65+
66+
```bash
67+
su - factorio
68+
```
69+
70+
2. Download Factorio server files:
71+
72+
```bash
73+
wget https://factorio.com/get-download/stable/headless/linux64 -O ~/factorio_headless.tar.xz
74+
```
75+
76+
3. Extract and prepare files:
77+
78+
```bash
79+
tar -xvf ~/factorio_headless.tar.xz -C ~/
80+
rsync -au ~/factorio/ ~/server/
81+
rm ~/factorio_headless.tar.xz
82+
rm -R ~/factorio/
83+
```
84+
85+
4. Setup server config:
86+
87+
```bash
88+
cp ~/server/data/server-settings.example.json ~/server/data/server-settings.json
89+
nano ~/server/data/server-settings.json
90+
```
91+
92+
(Edit settings as needed: server name, visibility, etc.)
93+
5. Create your first map save:
94+
95+
```bash
96+
~/server/bin/x64/factorio --create ~/server/my-save.zip
97+
```
98+
99+
6. Logout back to `root`:
100+
101+
```bash
102+
exit
103+
```
104+
105+
106+
***
107+
108+
## 4. Setup Systemd Service
109+
110+
As **root**, create a new `systemd` service:
111+
112+
```bash
113+
sudo tee /etc/systemd/system/factorio.service > /dev/null << 'EOL'
114+
[Unit]
115+
Description=Factorio Headless Server
116+
After=network.target
117+
118+
[Service]
119+
Type=simple
120+
User=factorio
121+
WorkingDirectory=/home/factorio/server
122+
ExecStart=/home/factorio/server/bin/x64/factorio --start-server /home/factorio/server/my-save.zip --server-settings /home/factorio/server/data/server-settings.json
123+
Restart=always
124+
125+
[Install]
126+
WantedBy=multi-user.target
127+
EOL
128+
```
129+
130+
Reload `systemd`:
131+
132+
```bash
133+
systemctl daemon-reload
134+
systemctl start factorio
135+
systemctl enable factorio
136+
```
137+
138+
139+
***
140+
141+
## 5. Done
142+
143+
Your Factorio headless server should now be running automatically on boot.
144+
145+
- To check status:
146+
147+
```bash
148+
systemctl status factorio
149+
```
150+
151+
- To stop/start:
152+
153+
```bash
154+
systemctl stop factorio
155+
systemctl start factorio
156+
```
157+
158+
159+
***
160+
161+
You now have a dedicated **Factorio server** running inside a Proxmox LXC container!
162+
163+
# Port Forwarding for Factorio Server
164+
165+
By default, Factorio uses port **34197/UDP**.
166+
If you want people outside your LAN to join your server, you need to make this port reachable from the internet.
167+
168+
## Port Forward on Your Router
169+
170+
On your home router/firewall:
171+
172+
1. Log in to your router admin panel.
173+
2. Look for **Port Forwarding / NAT / Virtual Server** settings.
174+
3. Add a new rule:
175+
- **Port**: `34197`
176+
- **Protocol**: `UDP`
177+
- **Destination IP**: IP address of your Factorio container (e.g., `192.168.1.50`).
178+
- **Forward To Port**: `34197`
179+
180+
Save and restart your router if necessary.
181+
182+
***
183+
184+
## Test External Connectivity
185+
186+
1. From outside your network (ask a friend, or use mobile hotspot):
187+
- Open Factorio → Multiplayer → Connect to your **public IP**.
188+
- Public IP can be found by searching *“what is my IP”* on Google.
189+
2. Make sure your local firewall (Proxmox host or container) is not blocking UDP traffic on port `34197`.
190+
191+
***
192+
193+
## Optional: Register with the Official Server List
194+
195+
Inside your `~/server/data/server-settings.json`, you can configure:
196+
197+
- `"name": "My Awesome Factorio Server"`
198+
- `"description": "Hosted on Proxmox LXC"`
199+
- `"visibility": "public"`
200+
201+
This will let your server appear in the official Factorio multiplayer browser.
202+
(Requires that port forwarding is working correctly.)
203+
204+
***
205+
206+
After completing this, you should be able to join by entering your **public IP (and port 34197)** in Factorio multiplayer.
207+
208+
209+
# Updating Factorio Server Automatically
210+
211+
Factorio releases updates often, so it’s a good idea to automate the update process. Below are steps to create a simple script that updates your server daily at 4 AM.
212+
213+
***
214+
215+
## Create the Update Script
216+
217+
Log in as **root** in your Proxmox LXC container and create the script:
218+
219+
```bash
220+
nano /root/update.sh
221+
```
222+
223+
Paste the following contents:
224+
225+
```bash
226+
#!/bin/bash
227+
228+
# Stop Factorio server before updating
229+
service factorio stop
230+
231+
# Download latest Factorio headless version
232+
sudo -u factorio wget https://factorio.com/get-download/stable/headless/linux64 -O /home/factorio/factorio_headless.tar.xz
233+
234+
# Extract files to the factorio home directory
235+
sudo -u factorio tar -xvf /home/factorio/factorio_headless.tar.xz -C /home/factorio/
236+
237+
# Sync new files into server directory (preserves saves & configs)
238+
sudo -u factorio rsync -au /home/factorio/factorio/ /home/factorio/server/
239+
240+
# Start the server again
241+
service factorio start
242+
243+
# Cleanup temporary files
244+
rm /home/factorio/factorio_headless.tar.xz
245+
rm -R /home/factorio/factorio/
246+
```
247+
248+
Save and exit (`CTRL+O`, then `CTRL+X`).
249+
250+
***
251+
252+
## Make the Script Executable
253+
254+
```bash
255+
chmod +x /root/update.sh
256+
```
257+
258+
259+
***
260+
261+
## Schedule Daily Automatic Updates
262+
263+
Edit root’s **crontab**:
264+
265+
```bash
266+
crontab -e
267+
```
268+
269+
Add this line at the bottom to run the update daily at 4:00 AM:
270+
271+
```cron
272+
0 4 * * * /root/update.sh > /dev/null 2>&1
273+
```
274+
275+
- `0 4 * * *` → every day at **4:00 AM**
276+
- `> /dev/null 2>&1` → silences script output
277+
278+
Save and exit the crontab editor.
279+
280+
***
281+
282+
## Verify Cron Setup
283+
284+
You can list cron jobs with:
285+
286+
```bash
287+
crontab -l
288+
```

0 commit comments

Comments
 (0)