How do I configure Windows Defender Firewall for MATLAB to communicate with external hardware such as Speedgoat?

279 views (last 30 days)
There is an issue with the Windows Defender Firewall preventing access to my Speedgoat target computer, or other hardware that I connect using Ethernet. How do I set up a rule in Windows Defender Firewall to allow a connection between MATLAB or my MATLAB-generated standalone application and my hardware?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Dec 2022
Edited: MathWorks Support Team on 17 Nov 2022
MATLAB, or any standalone applications generated with MATLAB, must be allowed to communicate on all types of networks through Windows Defender Firewall. We recommend going through the steps below with your IT team and/or a system administrator.
When allowing access for a standalone application, use Solution 2, or the Advanced Settings. 

SOLUTION 1: Use Windows Defender Firewall Prompt on First Connection

When you first try to connect to a target computer from a certain MATLAB release, Windows Defender Firewall prompts you to allow MATLAB to communicate on Private and Public networks:
1) Make sure that all options, including Private and Public options, are selected. 
⚠️ If the Public network option is not available (disabled/grayed out) -- refer to the documentation page about how to configure the Ethernet network as private using the Windows PowerShell
2) Click Allow access.

SOLUTION 2: Manually allow MATLAB through Windows Defender Firewall

In case you missed the above prompt, or did not check all options when prompted, you can configure the firewall manually:
1) Find Allow an app through Windows Firewall by using the Windows search.
2) Click the Change settings button if necessary to unlock the panel.
3) Click Allow another app.
4) Click Browse to browse for <matlabroot>\bin\win64\matlab.exe. Or, if configuring a standalone application, include the file path for your standalone executable. 
5) Click Network Types.
6) As the Network Type for MATLAB, select all options, including Private and Public.
⚠️ If the Public network option is not available (disabled/grayed out) -- refer to the documentation page about how to configure the Ethernet network as private using the Windows PowerShell
7) Click Add.
Important note: You must repeat the above procedure for every installed version of MATLAB or standalone application that you intend to use with (Speedgoat) hardware. If you upgrade MATLAB at any point in the future, you must either make sure to correctly configure the prompt as shown in SOLUTION 1 upon the first connection, or repeat SOLUTION 2 to manually configure the firewall for this new installation.  

ADVANCED SETTINGS: Configure firewall rules to allow incoming/outgoing traffic between the host and target.

If the above solutions don't help, try to configure additional Inbound and Outbound Rules in the Advanced Windows Defender Firewall settings:
1) Find Windows Defender Firewall with Advanced Security by using the Windows search.
2) Select Inbound Rules and New Rule.
3) For the Rule Type, select Program, and click Next.
4) Select This program path and browse for <matlabroot>\bin\matlab.exe. 
5) For the Action, select Allow the connection, and click Next.
6) For the Profile, select the DomainPrivate, and Public checkboxes, and click Next.
7) For Name, provide a Name for this inbound rule (for example, Simulink Real-Time inbound), and click Finish.
8) Select Outbound Rules and click New Rule.
9) Repeat steps 3 through 7 for the custom outbound rule.
If any of the above options are not available due to IT policy, or the communication still fails, please contact your IT helpdesk to verify your firewall rules.

Further Troubleshooting

If the above instructions don't help resolve the communication issues with your Speedgoat hardware, refer to the following MATLAB Answers post for further troubleshooting steps:
Yann Weyland
Yann Weyland on 11 Feb 2021
Edited: Yann Weyland on 11 Feb 2021
If I disable the firewall completely it works fine
The above rule is a general rule as it's not restricted to any particular program. Check among the inbound rules defined and search for your Matlab version currently used.
In my case I had 2 additional rules existing for the Matlab version I used that were blocking TCP and UDP connexions on any local address to any local on public networks.
I guess such rules are automatically created by Windows that ask us to take a decision the first time we're starting a program but we don't necessarily know at that moment what is relevant regarding our usage. This leads to the creation of specific rules disturbing our work in the end.
Editing these specific rules to permit connexions (instead of blocking) on relevant local and remote addresses was sufficient for me to remedy these firewall restrictions.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!