Troubleshooting
Why an M221 simulation fails with TCP error 10013 on port 51234
Short answer
Error 10013 is Winsock WSAEACCES: Windows refused the simulation runtime's bind to TCP port 51234 before any Modbus traffic ran. Find a listener with netstat -ano; if none exists, test the port against the Windows excluded-port ranges with netsh. Fix the ownership or exclusion on the Windows side, not in the PLC project.
On this page
Windows socket error 10013 is a permission denial, not a Modbus or program fault: when an M221 simulation in EcoStruxure Machine Expert launches, Windows refuses to let the runtime bind TCP port 51234, and the channel fails before any communication begins. The message reads TCPServer: Unable to create a channel (Port: 51234) – Error: 10013. Check if this port is already used by another server. Two causes cover nearly every case: a process already owns the port, or the port sits inside a Windows excluded range that ordinary processes may not bind. Work them in that order — netstat first, exclusions second — and leave the PLC project and the Modbus mapping alone; nothing in them produced this error.
What error 10013 means at bind time #
Error 10013 is the Winsock code WSAEACCES: "An attempt was made to access a socket in a way forbidden by its access permissions." The runtime hits it while creating its listening socket, before the first Modbus request is ever formed. Microsoft documents that a bind attempt on a port inside a Windows excluded range returns exactly this code, which is why the software's own hint — check whether the port is used by another server — is the right first move but an incomplete diagnosis: a port can be forbidden with no listener on it at all.
The causes that can produce WSAEACCES here:
- Another process holds the port with exclusive ownership.
- The port lies inside a Windows excluded-port range reserved for components such as Hyper-V and virtual networking.
- An endpoint-security policy denies the executable the right to open listening sockets.
One classic cause cannot apply: the privilege rule that reserves ports below 1024 for elevated processes, well under 51234.
One boundary matters before you change anything: this channel is not the Modbus service. The Machine Expert Basic simulator's Modbus server is documented at TCP port 502, the port registered for Modbus TCP, so the 51234 channel belongs to the simulation runtime itself. Re-pointing your Modbus client at another port cannot fix a bind failure on a socket the client never touches. The same split between ownership and permission appears wherever a runtime cannot bind — Unix socket bind denials on a Linux-based controller are diagnosed with the same two questions: who owns the socket, and what policy governs it.
Find the process that owns port 51234 #
Ownership is directly observable, so start there:
- Open a command prompt and run
netstat -ano | findstr 51234. - Read the local-address column. A line carrying
LISTENINGwith a local address such as0.0.0.0:51234or192.168.1.10:51234is your owner; note the process identifier in the last column. - Match that PID to an executable in Task Manager's Details tab.
- If it is a second copy of the same engineering software — a simulation left over from a session that never closed cleanly — close it through its own interface, re-run the command, and confirm the listener is gone.
- If it is a different application with a legitimate need for 51234, the conflict is named, and that application's documented port setting is the one to change.
A listener bound to 0.0.0.0 owns the port on every interface, so it collides with a later bind to any single local address as well. Do not end an unfamiliar process just to free the port: a Windows service doing real work can hold it, so identify it first and coordinate with whoever depends on it.
If no line shows LISTENING on 51234, stop hunting for an owner. The cause is an operating-system restriction.
Check the Windows excluded-port ranges #
Windows reserves blocks of the TCP dynamic range for operating-system components and denies them to applications, and those reservations never appear as listeners in netstat. Display them with:
netsh int ipv4 show excludedportrange protocol=tcp
Each row of the output is a start port and an end port. Testing your port against one row takes two subtractions, and both results must be non-negative for the port to fall inside.
Worked example: is 51234 inside the block #
Illustrative output, the shape you see on a machine where three blocks are reserved:
Start Port End Port
---------- --------
49671 49770
51154 51253
58234 58333
Row one: 49770 − 51234 = −1464, negative, so 51234 is above that block's end — outside. Row three: 58234 − 51234 = 7000, so 51234 is below that block's start — outside. Row two: 51234 − 51154 = 80 and 51253 − 51234 = 19; both non-negative, so 51234 sits inside the block, 19 ports short of its top edge. Windows returns WSAEACCES for any ordinary bind inside that row, which is the error on screen, with no listener anywhere.
The decision follows: an administrator either removes the component holding the reservation (Hyper-V or virtual networking the machine does not need) or restarts Windows, which re-runs the reservation logic and typically moves the blocks. Then verify before restarting the simulation — re-run the netsh command and confirm 51234 falls outside every row. Deleting exclusion rows by hand is not a fix; the components that created them re-create them, and some belong to services you want alive.
Rule out a security-policy denial #
When netstat shows no owner and no exclusion row covers the port, the remaining documented cause is policy:
- Endpoint-security software with application control can deny an executable the right to open listening sockets. Its own event log, read at the timestamp of the failed launch, names the runtime's executable if it made the denial. The fix is a policy exception from the security product's owner, never disabling the product.
- One elevated launch is a fair one-minute test: if the bind succeeds elevated and fails normally, a permission rule is following that executable, and the correction belongs in the rule.
- A firewall rule is not in play — it admits or blocks traffic reaching an existing socket and does not stop the socket from being created.
Match the fix to the finding #
| What you observed | Cause | The fix |
|---|---|---|
LISTENING on 51234; the PID is the same engineering software |
Duplicate simulation instance | Close it, confirm the listener disappears, restart once |
LISTENING on 51234; the PID is another application |
Port conflict between applications | Change that application's documented port setting; the simulator's channel has no project setting |
| No listener; an exclusion row covers 51234 | Windows reserved the port | Remove the reserving component or restart Windows, verify the ranges, restart the simulation |
| No listener, no exclusion; the security log names the executable | Application-control policy | Security owner grants the exception |
| Binds when elevated, fails when normal | Permission rule on the executable | Correct the rule; do not run elevated permanently |
Confirm the channel and test the Modbus link #
Restart the simulation once, after the single correction you chose, and check two things: the 10013 message does not reappear, and netstat -ano now shows the runtime listening on 51234. In every branch the decision has the same shape — free the port or clear the policy on the Windows side, change nothing in the project, and prove the fix by seeing the listener appear.
With the channel alive, the communication stack below it becomes testable for the first time. A good next step is to simulate a Modbus TCP SCADA link on one PC and prove the whole path before hardware enters the picture. When the supervisory side joins later, its reads carry failure modes of their own; Machine SCADA Expert Modbus TCP reads to a TM221 covers the addressing traps on this controller family.
Questions asked
Is TCP error 10013 a fault in my Modbus configuration?
No. The failure happens while the simulator is creating its listening socket, before the first Modbus request is ever formed. Winsock error 10013 means Windows denied the bind on port 51234 for a permission reason: an owned port, an excluded range, or a security policy. Your register mapping, slave ID and Modbus client settings are untouched by this error, and changing them will not clear it.
Why can port 51234 be blocked when netstat shows nothing listening on it?
Hyper-V and the Windows components behind virtual networking reserve blocks of the dynamic port range at boot, and those excluded ranges never appear as listening sockets. A port that worked yesterday can fail after a reboot moved the reservation, because the blocks are recomputed when Windows starts. That is why netstat stays empty while the bind still fails.
Will running the software as administrator clear error 10013?
Only ports below 1024 require an elevated process, and 51234 sits far above that line, so an elevated start is not the fix. It is still a useful one-minute test: if the bind succeeds elevated and fails normally, a security or permission rule is following that specific executable, and the answer is a policy correction, not a permanent habit of running the engineering tool as administrator.
Can I point the simulator at a different port instead?
Changing the Modbus client's port addresses the wrong socket. The simulator's Modbus service is documented at TCP port 502, while the failing channel on 51234 belongs to the simulation runtime itself, and no project setting for that channel is documented. The supported fix is to free 51234 on the Windows side, by closing its owner or clearing the exclusion that covers it.