IMD SolutionComputing LibraryShop main store

Troubleshooting

TCP client gets no SYN-ACK from a Windows PC server: firewall causes

Edge computing and IIoT Published 7 min read By IMD Solution engineering team

Short answer

When a SYN reaches the Windows PC but no SYN-ACK comes back, and other clients connect to the same server, the host firewall is dropping that source. A leftover block rule beats any allow rule, and an allow rule scoped to Domain or Private does nothing on a Public adapter. Delete the old rules, add one inbound TCP allow rule for the server port on the active profile, and confirm the SYN-ACK in a capture.

A firewall router on a DIN rail with three separate network leads: one leaving the panel, one to a compact PLC and one to a small Ethernet switch
On this page
  1. Three clues that point at the PC's firewall
  2. Firewall causes on the Windows host
  3. Evaluating the rules for a controller at 192.168.1.50 on a Public adapter
  4. Clear the stale rules and add one scoped allow rule
  5. Find the rule that still drops the SYN
  6. When the drop happens before the PC
  7. Questions asked

If an edge controller's TCP client sends a SYN to a server listening on a Windows PC and gets back nothing but its own retransmissions, while clients on other machines connect to the same server without trouble, Windows Defender Firewall on the PC is dropping that connection. In most cases the cause is a leftover inbound block rule from early testing, because a block rule overrides every allow rule. The other common cause is an allow rule scoped to a network profile that the controller-facing adapter isn't using. Delete the stale rules for the server program and port. Add one inbound TCP allow rule scoped to the controller's address and the active profile. Then confirm the SYN-ACK in a capture taken on the PC.

Three clues that point at the PC's firewall #

Taken together, these observations place the fault in the PC's host firewall, not in your code and not on the controller:

  • The SYN arrives at the PC. A capture tool on the PC sees packets at the adapter, below the firewall. A SYN in the capture proves the network delivered it, not that the server received it.
  • A stopped server answers with a reset. With nothing listening, the PC's TCP stack replies with RST and the client reports at once that nothing is listening. So the path is good and the port number itself is not being filtered.
  • A running server goes silent. Once the server program owns the listening socket, the SYN is dropped and nothing comes back. That is exactly how a rule behaves when it matches only while that program holds the port, such as a program-scoped block rule.
  • Other clients succeed. A client on another machine connects to the same server. Whatever is dropping the controller is scoped by profile, adapter or remote address. A missing listener would fail every client.

If clients written in different languages all show the same pattern, the client code is cleared as well.

Firewall causes on the Windows host #

Check these in order. The first two cover most cases.

  1. A stale inbound block rule. The first time a program listens on a port, Windows asks whether to allow it. Dismissing or declining that prompt leaves inbound block rules for the program, often on the Public profile. As the Windows Firewall rules documentation explains, an explicit block rule takes precedence over any conflicting allow rule. A more specific allow rule wins only when no block rule matches, so a new allow rule for the port cannot beat the old block.
  2. An allow rule on the wrong profile. Windows assigns the Public category to networks it cannot identify: a direct cable to a controller, a switch with no gateway, or the virtual adapter behind a virtual controller. Public blocks unsolicited inbound connections by default, so an allow rule limited to Domain and Private never applies to that adapter. Clients on the office network reach the PC through a Domain or Private adapter, which is why they work.
  3. Shields-up on the active profile. The setting "Block all incoming connections, including those in the list of allowed apps" makes a profile ignore every inbound allow rule without deleting any of them. Outbound connections the PC starts still work. The PC can still reach the controller when the controller is the server, and that hides the setting.
  4. A rule pinned to the wrong source or program. An allow rule limited to a subnet that doesn't include the controller never matches. Neither does a rule tied to the executable path of an earlier build.

Evaluating the rules for a controller at 192.168.1.50 on a Public adapter #

This is a hypothetical case built from documented firewall behavior, not a measured test.

Inputs:

  • Server port: TCP 5000. Microsoft's New-NetFirewallRule example uses this port, and it serves here as the example server port.
  • Controller address: 192.168.1.50, an example address on a direct link to the PC.
  • Adapter category: Public, because Windows cannot identify a network with no gateway (Set-NetConnectionProfile documentation).
  • Rule A: inbound allow, TCP, the server port, profiles Domain and Private. This is the documented example rule.
  • Rule B: inbound block for the server program on the Public profile, left behind by a dismissed first-run prompt.

The rule in words: the SYN passes only when zero block rules match and at least one allow rule matches on the active profile. Neither rule order nor specificity can rescue an allow rule from a matching block rule.

The arithmetic:

  • Before the fix: matching block rules = 1 (Rule B matches the Public profile, the server program and inbound TCP). Matching allow rules = 0 (Rule A excludes Public). With 1 block match, the SYN is dropped whatever the allow count is.
  • After deleting Rule B: block = 0, allow = 0. The SYN is still dropped, now by the Public profile's default inbound block.
  • After setting the adapter to Private: block = 0, allow = 1 (Rule A now matches). The SYN passes and the server answers with a SYN-ACK.

Result: the fix takes two changes, not one. Deleting the block rule alone leaves the connection dead, and fixing the profile alone leaves Rule B dropping the SYN.

Decision: if the block count is 1 or more, delete or narrow those rules first, whatever allow rules exist. If the block count is 0 and the allow count is 0, fix the adapter's profile or the rule's scope. Look past the firewall only when the block count is 0 and the allow count is at least 1.

Clear the stale rules and add one scoped allow rule #

  1. Run Get-NetConnectionProfile and note the alias and network category of the adapter that faces the controller.
  2. If that adapter is a dedicated controller network showing Public, set it to Private, for example Set-NetConnectionProfile -InterfaceAlias "Ethernet0" -NetworkCategory Private with your adapter's alias in place of Ethernet0. If you would rather keep it Public, include Public in the new rule's profiles.
  3. In Windows Security, open Firewall & network protection, select the active profile and check Incoming connections. Clear the block-all box if it is ticked.
  4. Open wf.msc, go to Inbound Rules, and find every rule that names the server program or the server port, including the ones the first-run prompt created. Delete the block rules and the leftover allow rules from earlier tests. Don't stack a new rule on top of them.
  5. Add the single rule below, restart the server, and capture on the PC's adapter. Success is a SYN, SYN-ACK and ACK from the controller's address, followed by data.

The rule to add #

The netsh form carries both the profile and the remote-address scope, so the port opens to the controller only and not to every host on the network:

netsh advfirewall firewall add rule name="TCP server from controller" dir=in action=allow protocol=tcp localport=5000 remoteip=192.168.1.50 profile=private

If you kept the adapter Public, add public to the profile list. The PowerShell form in the New-NetFirewallRule cmdlet reference sets the port and profile the same way, and like any allow rule, a matching block rule still overrides it:

New-NetFirewallRule -DisplayName "Allow TCP server" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 5000 -Profile Private

Find the rule that still drops the SYN #

If the capture still shows only retransmissions, have Windows name the filter. Under Advanced Audit Policy Configuration > Object Access, enable failure auditing for Audit Filtering Platform Connection, then let the controller retry. The Security log now records event 5157 for each dropped connection. The event shows the Application Name, the Direction, the source and destination address and port, the protocol number (6 for TCP) and the Filter Run-Time ID. Run netsh wfp show filters and match that ID to a rule name. That gives you the exact rule to delete or narrow. Once the connection works, turn the failure auditing back off so the Security log doesn't fill with drops from unrelated traffic.

If no 5157 event appears while the SYN keeps arriving and the server is listening, look at whatever else on the PC filters traffic, such as the firewall in an endpoint-security product.

When the drop happens before the PC #

If the capture on the PC never shows the SYN, the PC's firewall is not the problem. Look at the controller's own firewall, its app confinement and its routing. The steps for redirecting TCP 502 to 8502 on a Linux edge controller firewall show where that kind of rule lives on the controller side. Confinement denials logged while you install a client app are worth fixing, but they are not the cause once the SYN reaches the PC.

Once the handshake completes, a different set of faults takes over. A session that opens and then carries nothing is covered under a gateway that shows a TCP connection but sends no payload. A broker that rejects the client after TCP connects is covered in diagnosing an MQTT connect that fails when TCP works.

Questions asked

Does moving my allow rule to the top of the list in wf.msc help?

No. Windows Firewall does not evaluate rules from the top of the list down, so where a rule sits in the console changes nothing. Precedence decides the result: any matching block rule drops the packet, and only then does a more specific allow rule win over a broader one, for example a rule naming a single host address over one covering a whole subnet.

Why does a client running on the same PC connect when the controller cannot?

A client on the same PC reaches its own server over the loopback path, which the inbound firewall rules do not filter. A local test proves the server is listening and the code works. It tells you nothing about the rules applied to a packet arriving on a physical or virtual adapter, so test from a second machine on the controller's network instead.

Do I need an outbound rule so the PC can send the SYN-ACK?

No. Windows Firewall is stateful. Once an inbound allow rule admits the SYN, replies on that connection go out without a separate outbound rule, and outbound traffic is allowed by default on every profile. If your site policy has changed outbound to block, also check for an outbound block rule that names the server program.

Is it acceptable to switch the firewall off to prove it is the cause?

Only briefly, and only on an isolated controller network. The cleaner test keeps the firewall on and uses the failure audit event to name the filter doing the blocking. If you do switch a profile off for a minute, turn every profile back on with netsh advfirewall set allprofiles state on, then prove the scoped allow rule works while the firewall is running.

Keep reading

  • Troubleshooting

    Why a device cannot publish MQTT to a broker on your PC

    Point the device's client at the PC's LAN address, not 127.0.0.1 — loopback always means the device that opens the connection. Then confirm the broker listener is bound to the PC's LAN interface on TCP 1883 and that Windows Firewall admits inbound connections on that port from the plant subnet. Fix those three and the publish path works.

    Edge computing and IIoT

  • Troubleshooting

    Node-RED on IOT2050 shows Client Not Ready To Read At State init

    The error means the read fired while the Modbus client was still initializing, so its TCP connection to the simulator never opened. On a direct cable from the IOT2050 to a Windows laptop, the two causes are Windows Firewall dropping inbound TCP 502 and a simulator running as a client instead of a listening server. Prove the path with a port test, then fix the flow.

    Edge computing and IIoT

  • Troubleshooting

    Node-RED palette download fails though ping works on ctrlX CORE X3

    A passing ping proves IP reachability to the ping target only, not that the browser hosting the Node-RED editor can reach catalogue.nodered.org. In the reported case the PC browser's network proxy blocked that host, so the palette download failed identically on Node-RED 2.0.6 and 3.6.5. Disable or correctly configure that browser proxy first; only then check the controller's own route, DNS and proxy settings.

    Edge computing and IIoT

Why oversized history blocks spike historian RAM at merge