MT5 WebRequest Error 4014: Whitelist URLs on a VPS

WebRequest fails in MT5 until the URL is on the terminal's allowed list. Here is how to add it, test the connection from PowerShell, and read the 52xx error codes.

dns WindowsVPS Team calendar_today schedule5 min read
MT5 WebRequest Error 4014: Whitelist URLs on a VPS
tocOn this page 7 sections
  1. Why MT5 blocks WebRequest by default
  2. Step 1: Find the exact URL the EA calls
  3. Step 2: Add the URL in the terminal
  4. Step 3: Test the endpoint from PowerShell
  5. Step 4: Read the error code
  6. Keeping it working on a VPS
  7. FAQ

When an MT5 Expert Advisor calls WebRequest() and gets -1 with error 4014, the terminal is blocking the call because the target address is not on its allowed list. To fix it, open Tools > Options > Expert Advisors, tick Allow WebRequest for listed URL, add the exact scheme and host the EA calls (for example https://api.example.com), and click OK. If the error changes to a 52xx code after that, the URL is allowed and the problem is now the network, DNS or TLS. Test those from PowerShell on the VPS.

Why MT5 blocks WebRequest by default

MetaTrader treats outbound HTTP from MQL5 code as something you have to opt into. An EA you bought or downloaded could otherwise send account data anywhere, so the terminal only lets WebRequest reach addresses you have added yourself. Each terminal installation keeps its own list. If you run three MT5 terminals on one VPS, you have to configure all three.

WebRequest also has fixed limits that no setting changes:

  • It works only in Expert Advisors and scripts. Called from a custom indicator, it fails.
  • It does not run in the Strategy Tester, so a backtest that relies on it will fail even when live trading works.
  • It is synchronous. The EA waits up to the timeout you pass in, so a slow endpoint stalls OnTick().

Step 1: Find the exact URL the EA calls

Over RDP, open the terminal and check the Experts tab and the Journal tab in the Toolbox (Ctrl+T). Well-written EAs print the failing URL. If yours does not, the vendor's documentation or the EA's input parameters usually list the endpoint. If you have the source, search the .mq5 file for WebRequest(.

Note three things:

  • Scheme: http:// and https:// are different entries.
  • Host: api.example.com and example.com are different hosts. A subdomain has to be listed on its own.
  • Redirects: if the server redirects to another host, such as a CDN or a login domain, add that host too.

Step 2: Add the URL in the terminal

  1. In MT5, go to Tools > Options (Ctrl+O).
  2. Open the Expert Advisors tab.
  3. Tick Allow WebRequest for listed URL.
  4. Double-click the empty row under the checkbox (or click the green plus) and enter the base address, for example https://api.example.com. You don't need the path: listing the host allows every path under it.
  5. Repeat for each host, then click OK.
  6. Remove the EA from the chart and attach it again so it re-runs OnInit(). Check the Experts tab for a clean request.

The list is saved in the terminal's data folder (File > Open Data Folder), under config. If you move the terminal to a new server by copying that folder, the list comes with it. Still check it after the move, because a fresh install starts with an empty list. Our guide on moving MT4/MT5 to a VPS and keeping every EA and template covers which folders to copy.

Step 3: Test the endpoint from PowerShell

If the URL is listed and requests still fail, take MT5 out of the picture. Open PowerShell on the VPS and check DNS, the TCP connection and the HTTP response one at a time:

Resolve-DnsName api.example.com
Test-NetConnection api.example.com -Port 443
Invoke-WebRequest -Uri "https://api.example.com/health" -UseBasicParsing -TimeoutSec 10
  • If Resolve-DnsName fails, check the adapter's DNS servers with Get-DnsClientServerAddress.
  • If TcpTestSucceeded is False, something is blocking outbound traffic. Windows Firewall allows outbound connections by default, so check whether a hardening baseline changed that: Get-NetFirewallProfile | Select Name, DefaultOutboundAction. Also check whether the remote API only accepts whitelisted IPs. If it does, give the provider your VPS's public IP.
  • If the TCP test passes but Invoke-WebRequest fails with a TLS or secure channel error, the endpoint probably requires a newer TLS version or cipher than the OS offers. Check the System event log for Schannel errors, and keep the server patched.

Step 4: Read the error code

Have the EA print GetLastError() right after a -1 return. The common codes are:

  • 4014: function not allowed. The URL is not listed, the checkbox is off, or the call comes from an indicator or the tester.
  • 5200: invalid URL. Look for a missing scheme, stray spaces or a malformed address.
  • 5201: could not connect. This is a DNS, firewall or IP whitelist problem (see Step 3).
  • 5202: timeout. The server took longer than the timeout the EA passed in. Increase it or fix the endpoint.
  • 5203: the HTTP request failed. This often points to TLS or a dropped connection.

If WebRequest returns a positive number such as 401, 404 or 500, the call worked. That number is the server's HTTP status, so the problem is in the request (API key, path or body), not in MT5.

Keeping it working on a VPS

Change the allowed list only from the same Windows account the terminal runs under, because each user profile can have its own data folder. Also check the list again after the EA vendor changes their API domain. That is the most common reason a setup that worked for months suddenly starts logging 4014. For a full terminal setup that survives reboots, see MetaTrader 5 on a Windows VPS: Setup That Keeps Your EAs Trading 24/7. If you are building your own signal feed, the TradingView-to-MT5 webhook bridge shows a pattern where the EA calls a local endpoint. More trading setups are collected on our Windows VPS for Forex Trading page.

FAQ

Can I allow a local service like http://127.0.0.1?

Yes. Add http://127.0.0.1 (or http://localhost, which is a separate entry) to the list. Make sure the local service is running and listening before the EA starts.

Do I need to restart MT5 after adding a URL?

Usually not. Clicking OK applies the list. Reattaching the EA is enough to retry any setup it does in OnInit().

Why does the EA work live but not in the Strategy Tester?

WebRequest is disabled in the tester no matter what the allowed list says. EAs that depend on it need a fallback for testing, such as loading the data from a file.

Run this on your own Windows VPS

Get a Windows VPS from WindowsVPS in about 60 seconds, with full Administrator access over RDP, NVMe storage and the Windows license included.

Buy a Windows VPS →

dns

Written by the WindowsVPS Team

We run Windows Server VPS hosting and write these guides from the same setups our customers use: RDP, PowerShell, trading terminals and always-on bots. Questions about a guide? Contact us.

About WindowsVPS Windows VPS guides All articles

Ready to deploy your server?

Windows or Linux VPS — up and running in under 60 seconds.