Connection problemsio.netty.util.IllegalReferenceCountException: refCnt: 0
What the log looks like
io\.netty\.util\.IllegalReferenceCountException: refCnt: 0
io\.netty\.util\.IllegalReferenceCountException: refCnt: 0[\r\n\s]+at io\.netty\.buffer\.AbstractByteBuf\.ensureAccessible
How to fix it
- Open logs/latest.log on both the client and the server (or LAN host) and locate the full stack trace starting with io.netty.util.IllegalReferenceCountException: refCnt: 0.
- Look at the lines directly beneath AbstractByteBuf for mod package names or mixin tags (such as pl:mixin:APP:randompatches.mixins.json on PacketBuffer) to identify which mod touched the packet.
- If a network utility mod (like RandomPatches or similar packet-limit mods) appears in PacketBuffer.copy or NettyPacketEncoder, update it or disable its packet size mixin in its config file.
- Update your mod loader (Forge, NeoForge, or Fabric API) and the specific content mod shown in the trace, as certain loader releases (such as Forge 1.12.2 builds 2538–2542) had bugs that freed entity spawn buffers prematurely.
- If you are developing the mod causing this error, extract all values from the ByteBuf on the Netty thread before scheduling work on client.execute() / server.execute(), or explicitly copy/retain the buffer.
| Loaders | Forge, Neoforge, Fabric, Quilt, Server |
|---|
| Severity | Breaks something |
|---|
| Category | Connection problems |
|---|
Check your own log