How do I stop this lag?

When I do something on my Minecraft server, the world changes, but after a small period, my position and inventory goes back to where I was before. When I put stuff in a chest, it stays in the chest, and then I go get reset to my former inventory and position, and the stuff is still in the chest, so I have a duplicate. When I build, the building stays. But I just reset my position and inventory. This is happening to other players, by the way. How do I stop this lag?


This is called desync and rubber banding(because your position moves back and forth like a rubber band). What this basically means is your server can't keep up with what's happening in game and is ticking behind. This is why it appears like you have 2 of the same item, the client is desynced from the server (which sees only one). Assuming you have access to the console you can check to see if you get a message like "server is overloaded" or "last tick took x number of seconds"

If you are locally hosting you can try to allocate more ram to the server by modifying the run.bat file (or whatever it happens to be named) to allocate more ram. If this doesn't fix it you can look into getting a better cpu or IF your cup is compatible and you have PROPER(preferably water) cooling you can try overclocking your cpu.¹

If you are cloud hosting you can purchase(or in some cases earn) better computing resources. Or check if you can allocate more.

Independent of where you are hosting you can install plugins/mods that aim to reduce server lag, this isnt a mod like optifine which is client side, rather these are server side that run on the server to reduce lag. This answer showcases a few popular mods for fabric that do just that.

¹I am not responsible for any overclocking related hardware or software failures or damages that may be caused by overclocking your cpu