0X00000222

ERROR_PORT_MESSAGE_TOO_LONG (0X00000222) Fix

Windows Errors Intermediate 👁 7 views 📅 Jul 10, 2026

This error means a message sent between processes is bigger than the port can handle. Usually a broken named pipe or serial port config. Here's what to do.

1. Named Pipe Buffer Too Small (Most Common)

What's really happening: The ERROR_PORT_MESSAGE_TOO_LONG error (0x00000222) comes from the Local Procedure Call (LPC) mechanism inside Windows. But 9 times out of 10, you see it because a named pipe has a default buffer size that's too small for the data you're pushing through. I've hit this on Windows 10 22H2 and Server 2019 when sending XML blobs over 4KB between services.

The reason: Named pipes use a default maximum message size of 4096 bytes. If your app sends more than that in a single TransactNamedPipe or CallNamedPipe call, the LPC layer rejects it with error 0x222. The fix is to increase the buffer at creation time.

// Increase named pipe buffer to 64KB
CreateNamedPipe(
    L"\\.\pipe\MyApp",
    PIPE_ACCESS_DUPLEX,
    PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
    PIPE_UNLIMITED_INSTANCES,
    65536,  // out buffer
    65536,  // in buffer
    5000,
    NULL
);

If you can't change the server code, you can sometimes adjust the registry key HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\PipeSize (DWORD, default 4096, max 65535). Reboot after changing it. But honestly, fixing the code is more reliable.

2. Serial Port Baud Rate or Handshaking Mismatch

You can also get error 0x222 on serial ports (COM1, COM2) when the baud rate or flow control settings don't match between the two ends. I've seen this happen on industrial PCs running Windows 10 IoT Enterprise 2021, where a barcode scanner sends data at 115200 baud but the app expects 9600.

The LPC port used for serial I/O has a small internal buffer (around 2KB). If data comes in faster than the app reads it, the buffer fills and the next write fails with this error. The real fix: match the settings on both ends, and increase the receive buffer size if possible.

// Set serial port with 64KB buffer
DCB dcb = {0};
GetCommState(hSerial, &dcb);
dcb.BaudRate = CBR_115200;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
SetCommState(hSerial, &dcb);

COMMTIMEOUTS timeouts = {0};
timeouts.ReadIntervalTimeout = 50;
timeouts.ReadTotalTimeoutConstant = 50;
timeouts.ReadTotalTimeoutMultiplier = 10;
timeouts.WriteTotalTimeoutConstant = 50;
timeouts.WriteTotalTimeoutMultiplier = 10;
SetCommTimeouts(hSerial, &timeouts);

SetupComm(hSerial, 65536, 65536);  // increase internal buffer

Check the device manager's port settings (COM port properties → Advanced → Receive Buffer). Lower it if you see overruns, raise it if you get timeouts. It's a balancing act.

3. LPC Port Message Length Limit (Advanced, Rare)

Windows has a hard limit on the size of a single LPC message: 0x1F4 (500) bytes for the LPC port itself. This is a kernel limit, not a named pipe limit. You'd only hit this if you're using undocumented NtCreatePort or NtReplyPort APIs directly (some custom IPC libraries do this).

The real cause: The LPC port can only carry a small header plus 256 bytes of data. Anything above that forces Windows to copy the data to a shared section object, and if the section is too small, boom—error 0x222. Microsoft's official recommendation: don't use LPC directly. Use named pipes or ALPC (Advanced Local Procedure Call) instead.

If you're stuck with legacy code that uses LPC, you can increase the section size by passing a larger MaxConnectionReplyLength to NtCreatePort. But I haven't seen this work reliably after Windows 8.1. The only real fix: rewrite the IPC layer to use named pipes or sockets.

Quick Reference Table

CauseLikelihoodFix TimeDifficulty
Named pipe buffer too small90%10-30 minIntermediate
Serial port mismatch8%15-45 minIntermediate
LPC port limit2%1-4 hoursAdvanced

Was this solution helpful?