How to Auto-Restart and Auto-Login MT4 and MT5 After a VPS Reboot

How to Auto-Restart and Auto-Login MT4 and MT5 After a VPS Reboot

You set up your expert advisor, leave it running, and everything looks fine until a Monday morning when the chart is gone. The VPS restarted over the weekend, MetaTrader did not come back, and the EA missed every signal since. Getting MT4 and MT5 to restart by themselves is a common request, and the usual fixes solve only part of it. This guide goes through what actually has to happen, the do-it-yourself routes on Windows, and where each one falls short.

What has to happen after a restart

For an EA to be trading again, four separate things must succeed, with nobody at the keyboard:

  1. Windows starts and a user session exists for MetaTrader to run in.
  2. The terminal starts.
  3. The terminal logs back into the trading account.
  4. The chart comes back with the EA attached and AutoTrading on.

Most guides cover step 2. A failure at any of the others looks the same from the outside: a terminal that is open, or a server that is up, and an EA that is doing nothing.

Method 1: the Windows Startup folder

Put a shortcut to terminal.exe (MT4) or terminal64.exe (MT5) in the Startup folder. Press Win+R, type shell:startup, and drop the shortcut in.

The catch is that the Startup folder runs when a user logs in, not when the machine boots. After a reboot, nothing starts until someone connects over Remote Desktop, unless you also set up automatic sign-in for that account. Automatic sign-in stores the account's password on the server and leaves a logged-in desktop running, so weigh that before enabling it.

Method 2: Task Scheduler

You can create a task with the trigger "At log on" and the same program. It has the same dependency on a logged-in session, because MetaTrader is a desktop program and needs a desktop to draw on. A task set to "At startup" that runs whether or not the user is logged on usually gives you a terminal with no visible window, which is hard to check and manage.

Task Scheduler does add one thing the Startup folder lacks: you can have it restart the program on failure. It only notices the process exiting, though. A terminal that has frozen but is still running counts as healthy.

Method 3: a startup configuration file

This one handles steps 3 and 4. Both platforms accept a configuration file at launch with the login, server, expert, symbol and timeframe, so the terminal opens a chart with your EA. Check the "Platform Start" section of the MetaTrader help for the exact keys, since they differ between MT4 and MT5.

Two things to watch:

  • If the configuration holds the account password, it sits in a plain text file on the server.
  • Without a password in it, you rely on the terminal having saved the account. Check this on your own setup by rebooting and watching the connection state, rather than assuming.

Method 4: a watchdog script

To catch a terminal that hangs, people write a script or use a monitoring tool that restarts the process. Doing this well means answering a harder question than "is the process alive": is the terminal connected to the broker, and is the EA still running? That usually ends with a small EA or indicator that writes a heartbeat file, plus a script that reads it. It works, but now you are maintaining software of your own, and if it breaks you find out when the trades stop.

What still goes wrong

  • No alert. Even a perfect restart setup is silent. If it fails, you learn about it from your account statement.
  • Login dialogs and update prompts. Any window waiting for a click can stop a terminal from doing its job.
  • Settings drift. Starting from a configuration file can bring an EA back with different inputs than the ones you changed by hand on the chart, unless the inputs are saved in a preset that the file points to.

Whichever method you use, test it properly: reboot the server on a demo account, touch nothing, and check that the terminal reconnects and the EA is trading.

If you would rather not build this yourself

This is the problem our MetaTrader VPS was built to take off your hands. After a reboot, a crash or a frozen terminal, each MT4 or MT5 terminal starts again, logs back into its account and reattaches its EA with the inputs you saved. There is no sign-in to arrange, because terminals do not depend on anyone being connected. The account password is stored encrypted on your own server, and if a terminal has to be restarted, or an EA reports an error, you get a Telegram message.

A Windows VPS you run yourself is still the better choice if you need full control of the machine or Windows software beside MetaTrader. If all you want is the EA kept running, see the plans.

Frequently asked questions

Does MetaTrader restart by itself after a VPS reboot?

Not by default. On Windows you need one of the methods above, and usually automatic sign-in as well.

Will my EA turn back on by itself?

Only if the terminal reopens the chart with the EA on it and AutoTrading is enabled. Test it on a demo account after a real reboot.

Does a restart close my open trades?

No. Open positions stay on the broker's server, along with their stop-loss and take-profit levels. What stops during an outage is whatever the EA manages itself, such as trailing stops or closing logic, until it is running again.

Trading carries a high risk of loss. This article is about keeping software running and is not trading or investment advice.

Related reading

See MetaTrader VPS plans ← Back to blog