Main Content

Troubleshoot Communication Failure Through Firewall (Windows)

When attempting to connect to the Speedgoat® target computer by using Simulink Real-Time Explorer, this error message appears.

Error: Cannot connect to target 'TargetPC1': Cannot connect to target.

A firewall issue can cause the cannot connect to target error.

Even though the connection fails, clicking on the Update button or Reboot button in Simulink Real-Time Explorer works. These operations indicate that the target computer can be reached through the Ethernet port.

What This Issue Means

In R2020b and later releases, Simulink® Real-Time™ uses a protocol for the development-to-target computer connection that is blocked by default in Window Defender Firewall for networks classified as Public. Windows also classifies all Ethernet connections as Public by default.

If you do not select the correct options when first running MATLAB®, it is can be possible to ping, update, and reboot the target computer from MATLAB. But, these incorrect option selections prevent communication connection to the target computer. This communication connection is necessary to load and run real-time applications on the target computer.

Try These Workarounds

Resolve this issue by allowing MATLAB to communicate on all types of networks. Apply this setting when prompted on first connection or apply this setting later through the Windows Defender Firewall Allow an app through Windows Firewall selection. If that is not possible due to privilege restrictions, the issue can also be resolved by changing the classification of the Ethernet interface used for development-to-target computer connection from Public to Private.

Note

If you develop a compiled application as described in Create Standalone Instrument Panel App by Using Application Compiler, apply these workarounds to let the compiled application communicate with the target computer through the firewall.

Allow MATLAB for Public and Private Networks by Using Prompt

When you first try to connect to a target computer, Windows Defender Firewall prompts you to allow MATLAB to communicate on Private and Public networks. Make sure that both Private and Public options are selected. Only one is selected by default.

A Windows Defender Firewall issue can cause the cannot connect to target error.

Click Allow access.

Manually Allow MATLAB for Public and Private Networks

From the Windows® Start menu, search Allow an app through Windows Firewall.

A Public and Private Networks configuration issue can cause the cannot connect to target error.

Click the Allow an app through Windows Firewall option.

Scroll down in the Allowed apps and features list and find the MATLAB release that you are using. This rule should apply to the application path:

C:\Program Files\MATLAB\RXXXXx\bin\win64\matlab.exe

where RXXXXx is the release number. You can show this path by double-clicking on the rule. If missing, this rule can be added manually.

If both Private and Public check boxes are selected, see Configure Development-to-Target Computer Ethernet Interface as Private.

A Public and Private Networks configuration issue can cause the cannot connect to target error.

Click the Change settings button and confirm the security dialog. Make sure that the Private and Public boxes are selected. A Domain option or others may be available, but these options are not relevant for the MATLAB network access configuration.

A Public and Private Networks configuration issue can cause the cannot connect to target error.

Configure Development-to-Target Computer Ethernet Interface as Private

You can use the Windows UI or PowerShell command window to configure development-to-target computer Ethernet interface as private.

Windows UI Method

The Windows UI method is straightforward, but may not be available depending on your system configuration. If not, use the PowerShell Command Window Method.

  1. Right-click on the Wi-Fi® or Ethernet network icon in the lower right corner of the Windows taskbar (next to the clock).

  2. Select Open Network & Internet settings.

  3. Under the Ethernet section, click Properties.

  4. Select the radio button for Private.

PowerShell Command Window Method

  1. Right-click on the Windows Start menu and click the Windows PowerShell (Admin) selection.

  2. Run the command Get-NetConnectionProfile.

  3. Find the name of the Ethernet interface that you are using for development-to-target computer communication.

  4. Enter the command Set-NetConnectionProfile.

  5. Use the interface name that you find as the Name argument.

  6. Confirm the changes by running Get-NetConnectionProfile.

For example, if the interface is named Unidentified network, enter the command:

Set-NetConnectionProfile -Name "Unidentified network" -NetworkCategory "Private"

You can use the PowerShell command window to get this configuration.

Confirm Successful Configuration

To confirm successful configuration, in Simulink Real-Time Explorer or in the Simulink Editor on the Real-Time tab, click the Disconnected button. Confirm that the button label changes to Connected.

If the label does not change to Connected, the connection problem persists. Contact a systems administrator for further assistance. Administrator credentials may be required to configure the Windows Defender Firewall, or there may be another firewall on the development computer that requires configuration. A systems administrator may need to allow communications on specific ports or add more specific firewall rules.

Related Topics

External Websites