How to Run MetaTrader 4 on a Linux VPS with Wine

Last updated 23 April 2026

_Published:_ 22 April 2026. _Configurations reflect current WineHQ community practice for MetaTrader; in-house verification by AFRICLOUD Engineering is scheduled, and this guide will be revised with pinned versions once that pass is complete._

Why run MetaTrader 4 on a Linux VPS?

Most retail forex guides assume you need a Windows VPS to run MetaTrader 4 (MT4), MT5, and your Expert Advisors (EAs) round the clock. You don't. Wine — a mature, open-source Windows compatibility layer — has run MT4 on Linux for well over a decade, and a sizeable share of long-running EA traders have moved that way. The attraction is twofold: Linux VPS pricing is materially lower than Windows VPS (no Microsoft licence fee), and the hardware footprint of a headless Ubuntu + Wine + MT4 stack is smaller, so modest plans go further.

This guide walks through the full procedure end to end: provision a Linux VPS, harden it, install a minimal desktop, set up Wine, install MT4, connect to your broker, load an EA, and — the part most tutorials skip — keep everything running after you disconnect your RDP client. You should finish with an MT4 terminal that continues running between RDP sessions and that can be recovered quickly after a reboot.

The guide is written for our Lisbon data centre, which sits 18–22 ms from Equinix LD4 and LD5 in London — the facilities where IC Markets, Pepperstone, and most other mainstream forex brokers serving European and Asian retail traders host their MT4 trade servers. For EAs that care about order-execution latency, that proximity is the whole point of running your terminal here rather than on a generic cloud region.

Before you begin

You will need:

  • A broker account and your MT4 login credentials (server, login number, password)
  • The MT4 installer from your broker's download page (most brokers ship their own branded build)
  • An RDP client on your laptop — Microsoft Remote Desktop on Windows or Mac, or Remmina on Linux
  • About 30–45 minutes for the first-time setup

Comfort with the Linux command line is assumed — you should be happy running sudo apt commands and editing a config file with nano or vim.

Step 1: Choose and provision the VPS

MT4 itself is light. EAs vary — a single simple EA is trivial; a chart-heavy terminal with several indicators plus multiple running EAs wants more memory.

Practical plan tiers for MT4 + Wine + XFCE:

  • Cloud VPS 2 — 1 vCPU, 2 GB RAM. Floor for a single MT4 terminal with one EA. Works but leaves little headroom.
  • Cloud VPS 3 — 2 vCPU, 3 GB RAM. Comfortable for one or two EAs with indicators running.
  • Cloud VPS 4 — 2 vCPU, 4 GB RAM. Recommended if you run multiple EAs, perform occasional backtesting inside the terminal, or want a buffer for MT4 updates.

Select the Lisbon (eu-lis-1) location at checkout for the 18–22 ms LD4/LD5 latency story.

Operating system: choose Ubuntu 24.04 LTS or Ubuntu 22.04 LTS. Both work; 24.04 is the current long-term-support release and carries newer Wine builds in the WineHQ repository.

Provision a Linux VPS

Step 2: Harden the fresh server

A fresh VPS accepts SSH on the public internet; within minutes it will see brute-force probes. Do the hardening before you install anything else.

Create a non-root user, add them to sudo, and disable password-based SSH:

sudo adduser trader
sudo usermod -aG sudo trader
sudo rsync -a /root/.ssh /home/trader/
sudo chown -R trader:trader /home/trader/.ssh

Edit /etc/ssh/sshd_config and set:

PermitRootLogin no
PasswordAuthentication no

Then sudo systemctl restart ssh. Test the new login from a second terminal before you close this one.

Enable the firewall, allowing only SSH and RDP (port 3389):

sudo ufw allow OpenSSH
sudo ufw allow 3389/tcp
sudo ufw enable

Install fail2ban for xrdp brute-force protection — RDP on port 3389 is a constant target:

sudo apt install fail2ban

By default, fail2ban protects SSH; enable the xrdp jail by creating /etc/fail2ban/jail.d/xrdp.local with:

[xrdp]
enabled = true
port = 3389
filter = xrdp
logpath = /var/log/xrdp.log
maxretry = 5
findtime = 600
bantime = 3600

Then sudo systemctl restart fail2ban.

Step 3: Install the XFCE desktop

XFCE is the right choice for a forex VPS: lightweight (RDP sessions feel responsive even on single-vCPU plans), stable, and has the straightforward panel layout MT4 users expect. Install it minimally:

sudo apt update
sudo apt install xfce4 xfce4-goodies dbus-x11

Tell the login system to launch XFCE as the session type:

echo "xfce4-session" > ~/.xsession

Step 4: Install and configure xrdp

xrdp is the Linux implementation of the Remote Desktop Protocol — it lets a Windows or Mac Remote Desktop client connect to your Linux VPS as if it were a Windows host.

sudo apt install xrdp
sudo adduser xrdp ssl-cert
sudo systemctl enable --now xrdp

Make xrdp start XFCE for your user by editing /etc/xrdp/startwm.sh — comment out the existing session-selection lines and add startxfce4 at the end.

Set a strong password on the trader account for RDP sign-in (this is separate from your SSH key):

sudo passwd trader

Connect from your RDP client using your VPS's public IPv4, username trader, and the password you just set. You should see the XFCE desktop. If the session disconnects immediately after login, see the troubleshooting section.

Step 5: Install Wine from WineHQ

Do not install wine from the Ubuntu repositories — it is several versions behind and has known MetaTrader quirks. Use the WineHQ-maintained package instead.

Enable 32-bit architecture support (MT4 is a 32-bit Windows application, and MT5 still ships both 32- and 64-bit variants depending on broker):

sudo dpkg --add-architecture i386

Add the WineHQ repository and key:

sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key

For Ubuntu 24.04 (Noble):

sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/noble/winehq-noble.sources

For Ubuntu 22.04 (Jammy), replace noble with jammy in the URL above.

Install the stable branch:

sudo apt update
sudo apt install --install-recommends winehq-stable

Confirm the version:

wine --version

Why stable and not staging? WineHQ ships three branches — stable, development, and staging. Staging carries the newest compatibility patches but rolls forward aggressively. For a trading terminal you expect to run untouched for weeks at a time, stable's slower cadence is the right trade-off.

Step 6: Prepare the Wine prefix

The Wine prefix is Wine's equivalent of a Windows install — a directory holding the registry, system libraries, and your installed applications. Initialise it:

winecfg

A dialog asks whether to install Mono and Gecko — say yes to both. When the main config window appears, set the Windows version to Windows 10 and close it.

Install the MetaTrader runtime prerequisites using winetricks:

sudo apt install winetricks cabextract
winetricks -q corefonts vcrun2019

corefonts gives Wine the Microsoft fonts MT4 uses for chart labels; vcrun2019 installs the Visual C++ runtime MT4's native DLLs need. The -q flag skips the interactive prompts.

Step 7: Get the MetaTrader 4 installer from your broker

Most brokers ship their own branded MT4 build. Go to your broker's download page and grab their installer .exe. If your broker only links to the Windows installer, that is the correct one — Wine runs Windows executables directly.

From the RDP session, use Firefox (install via sudo apt install firefox) to visit the broker site and save the installer to ~/Downloads. Alternatively, wget the installer URL directly from a terminal.

Examples of broker installer naming: icmarkets4setup.exe, pepperstone4setup.exe, exness4setup.exe. They are all variants of the same MetaQuotes base.

MT5 is distributed differently: MetaQuotes still hosts the generic MT5 terminal at mql5.com, and individual brokers ship their own branded MT5 builds as well. For this guide we focus on MT4.

Step 8: Install MetaTrader 4 under Wine

Run the installer:

cd ~/Downloads
wine icmarkets4setup.exe

Step through the installer. When it completes, MT4 launches and shows the broker's server selection. Enter your login number, password, and the broker server name (the exact format varies by broker — for IC Markets it resembles ICMarketsSC-Live04; your broker's onboarding email confirms the correct server string). MT4 connects and you are in.

A launcher for MT4 appears in the XFCE applications menu. If you prefer a desktop shortcut, right-click the desktop → Create Launcher and point it at the MT4 terminal.exe inside ~/.wine/drive_c/Program Files (x86)/.

Step 9: Keep MT4 running between RDP sessions and after reboots

This is the step that separates a working forex VPS from one that silently fails overnight. Two behaviours matter: what happens when you close your RDP window, and what happens when the VPS reboots.

Between RDP sessions: MT4 continues

By default, xrdp keeps your XFCE session running after you disconnect. Reconnecting to the same user with the same password resumes the existing session, and MT4 keeps trading throughout the disconnect. Do not click "Log Out" inside XFCE when you finish — that terminates the session and kills MT4 with it. Close the RDP client window (or tick "Leave running" if your client offers the option).

This gives you a trading terminal that survives overnight, over weekends, and through client-side network blips without any extra configuration.

After a reboot: two options

Reboots are rarer than disconnects, but they happen — kernel security updates, plan resizes, and so on. Here the behaviour depends on which approach you choose.

Option A — Manual restart after reboot (recommended for most traders)

Add MT4 to XFCE's autostart so it launches automatically the next time you log in to a desktop session. Create ~/.config/autostart/mt4.desktop:

[Desktop Entry]
Type=Application
Name=MetaTrader 4
Exec=wine "C:\\Program Files (x86)\\MetaTrader 4\\terminal.exe"

After a reboot, RDP into the VPS once. XFCE starts, autostart fires, MT4 launches, and your EA resumes trading. You do not need to stay connected after that — close the RDP window and MT4 keeps running.

This is the simpler pattern, and for traders who reboot a handful of times per year (typically only for kernel upgrades) it is the right choice. The downside is obvious: if the VPS reboots while you are asleep, MT4 will not be trading until you RDP in to trigger the autostart.

Option B — Fully headless with a systemd user service (advanced)

For fully automatic MT4 startup on boot — no RDP login required — run MT4 under a virtual framebuffer (Xvfb) as a systemd user service. This is more fragile: XFCE panel tray icons do not always initialise without a real session, and errors inside MT4 are harder to observe since there is no real screen.

First, enable user lingering so systemd user services run without an active login:

sudo loginctl enable-linger trader

Then create ~/.config/systemd/user/mt4.service:

[Unit]
Description=MetaTrader 4 under Wine (headless)
After=graphical.target

[Service]
Type=simple
Environment=DISPLAY=:99
ExecStartPre=/usr/bin/Xvfb :99 -screen 0 1920x1080x24
ExecStart=/usr/bin/wine "C:\\Program Files (x86)\\MetaTrader 4\\terminal.exe"
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target

Install Xvfb (sudo apt install xvfb), then enable and start the service:

systemctl --user daemon-reload
systemctl --user enable --now mt4.service

You can still RDP in to observe and change settings — use a separate user, or stop the headless service first (systemctl --user stop mt4.service), RDP in, change what you need, and restart the service.

We recommend Option A for most traders and Option B only if you need the VPS to resume trading autonomously after an unattended reboot and are comfortable debugging the Xvfb setup yourself.

Step 10: Verify your EA is still running

From an SSH session (no RDP needed), check the processes:

ps aux | grep -i terminal.exe

You should see the wine terminal.exe process owned by your trader user. To check memory and CPU:

top -u trader

If the process is missing and you used Option A above, RDP in once to trigger the autostart. If you used Option B, check the service status with systemctl --user status mt4.service and the logs with journalctl --user -u mt4.service.

Troubleshooting

The errors below are the ones most commonly reported by MT4-on-Wine users in the WineHQ community forums:

MT4 installer runs but the main window is blank or shows rectangles instead of text. Missing fonts. Re-run winetricks -q corefonts and restart the terminal.

"Application Error" dialog on first launch of MT4. Missing Visual C++ runtime. Run winetricks -q vcrun2019. If the error persists, also add vcrun2015 and vcrun2017.

MT4 connects but the EA does not attach to the chart. Check that AutoTrading is enabled (the button in the toolbar should be green) and that the EA is permitted to trade live under Tools → Options → Expert Advisors. These are MT4 settings, unrelated to Wine.

RDP session disconnects immediately after login. xrdp and the running XFCE instance have fought over the display. Kill any running xfce4-session processes (pkill -9 xfce4-session) and reconnect. If it repeats, check that ~/.xsession contains xfce4-session and that /etc/xrdp/startwm.sh does not start a second session.

MT5 auto-updated and now will not launch. MetaQuotes pushes MT5 updates to the terminal, and sometimes the new build ships a native component Wine does not yet support. Re-run winecfg and set Windows version to the previous value, or wait for the next WineHQ stable release.

Terminal dies when the RDP window closes. You signed out of XFCE instead of disconnecting. Reconnect, do not click "Log Out" in the XFCE menu; close the RDP client window instead.

Latency to broker servers

For order-driven EAs, the round trip between your terminal and the broker's trade server matters. From our Lisbon data centre, typical latency to Equinix LD4 and LD5 in London — where the overwhelming majority of forex brokers serving European retail traders host their MT4 servers — falls in the 18–22 ms range. That is competitive with dedicated forex-VPS providers who colocate inside LD4 itself, and materially better than cloud regions in Johannesburg, the Middle East, or further afield.

To measure it yourself from your own connection, we host a public Looking Glass that runs live pings and traceroutes from our routers in Lisbon and Johannesburg to any destination you name. Test against your broker's price-feed hostname:

AFRICLOUD Looking Glass

Broker compatibility

MT4 and MT5 compatibility under Wine is tracked by the WineHQ AppDB — a community-maintained database of Windows software compatibility ratings — and discussed in the WineHQ community forums. MT4 has been tested under Wine for over a decade with broadly favourable community reports. MT5 is a heavier application and compatibility varies slightly between builds: the core terminal and charting function reliably, while the MQL5 strategy tester and some of the newer chart features can be more finicky.

The authoritative current status for your specific broker build is the community entry:

Branded MT4 builds from IC Markets, Pepperstone, Exness, XM, FBS, FxTM, Admiral Markets, and FP Markets are commonly reported as working on Wine. Variations between branded builds are small — they share the MetaQuotes core — so a compatibility issue with one build is unusual and typically a sign that the broker has shipped an unexpectedly old or customised binary. If your broker's build behaves unexpectedly, check the AppDB comments and the WineHQ forum before assuming Wine is at fault.

Known limitations

This guide is a working setup, not a managed service. Things to know:

  • Wine is volunteer-maintained. Compatibility is excellent today but is never guaranteed across future updates.
  • MetaQuotes pushes MT5 terminal updates automatically. A new MT5 build occasionally lands that Wine does not yet handle; you may need to wait days to weeks for a WineHQ patch.
  • xrdp is not the native Windows RDP stack. It works well, but you may notice minor differences — clipboard sync quirks, occasional redraw delays, no seamless window mode.
  • We do not monitor your terminal or your trades. This is a self-managed VPS; trading correctness is your responsibility.

Traders who want a fully managed, one-click Windows MT4 setup with single-vendor support should look for a Windows-based managed forex VPS instead.

Frequently asked questions

Does this guide work for MetaTrader 5? Mostly, with adjustments. Install your broker's MT5 installer (or the generic MT5 from mql5.com) instead of MT4; the desktop, Wine, and xrdp steps are identical. MT5 is a newer and heavier application than MT4, and MetaQuotes pushes terminal updates more aggressively, so expect occasional auto-update hiccups. The core trading and charting work; the MQL5 strategy tester and some newer features are the areas most likely to misbehave.

Can I run multiple MT4 instances on the same VPS? Yes. Install each broker's terminal into a separate Wine prefix (set WINEPREFIX=~/.wine-icmarkets wine icmarkets4setup.exe, repeat with another prefix for the next broker) and add a separate autostart entry or systemd unit for each. Plan for roughly 400–600 MB of RAM per MT4 instance.

What happens when the broker pushes a MetaTrader update? MT4 updates are usually small and apply cleanly under Wine. MT5 updates are more frequent and occasionally break Wine. If that happens, your EA stops; you will need to either roll MT5 back to the previous build or wait for a WineHQ update. Keep an eye on the WineHQ AppDB comments and the broker's own forum.

Why Linux instead of a Windows VPS? Price and resource density. A Linux VPS with Wine typically runs MT4 at roughly two-thirds the RAM footprint of the equivalent Windows Server configuration, and carries no Microsoft licence fee, so plans are materially cheaper. For most retail traders running one or two EAs, the trade-off pays off. For institutional workloads or traders who rely on Windows-only forex tools, a Windows VPS is the right choice.

Which AFRICLOUD plan should I pick for MT4 with one EA? Cloud VPS 2 ($40/month — 1 vCPU, 2 GB RAM) is the floor and works for a single EA. If you run indicators alongside or plan to add a second EA later, start on Cloud VPS 3 ($60/month — 2 vCPU, 3 GB RAM) for comfort.

Can I pay with cryptocurrency? Yes — we accept Bitcoin, USDT, Ethereum, and over 100 other cryptocurrencies in addition to card and PayPal. See how to pay with cryptocurrency for the payment flow.

Ready to start?

Provision a Linux VPS in our Lisbon data centre and follow this guide end to end:

Order a Cloud VPS

_This guide is provided as technical documentation only and is not financial advice. Your choice of broker, Expert Advisor, and trading strategy is your own responsibility. AFRICLOUD does not monitor your trading performance._