How To Fix Lag on Your Minecraft Server

12 min. readlast update: 10.18.2023

The worst thing that can happen to a Minecraft server is lag, and while having the best hosting can be a big help, optimizing your server to be as lag-free as possible will go a long way as well. 

🖥️ Choosing the Right Server Software

First things first, it is important to note that you need to be using Paper or PurPur as your server software unless you are running a modded server. We have a dedicated guide on optimizing modded servers if that's the case. 

There are two main reasons for this.

The first is that Paper and PurPur are more optimized than any other Minecraft server software out there. They are designed to reduce lag in Minecraft as much as possible, especially when they are configured correctly, which we will go over later. 

The second is that they add in a few features (/spark profiler start and /tps) that can be very helpful for diagnosing lag.

undefined

🚀 Optimizing Your Server Config Files

With your server software selected, we can move on to configuring the files your server has associated with it

⚒️ If you have a modded or vanilla server, the "server.properties" optimizations can still be done. However, everything else is limited to Paper and PurPur servers. 

server.properties

The server.properties file is one that every Minecraft server has. There aren't a ton of settings that will impact lag, but there are a few worth mentioning. 

view-distance: 4-8 

Your view distance affects how many chunks load around players. For survival worlds, 6-8 should be the ideal setting here. However, on SkyBlock and servers where view distances is less important, turning it down to 4 can be a huge performance boost. 

simulation-distance: 3-5

This affects the distance in chunks around players in which things around the will happen. For example, things like crops and saplings growing, furnaces working, animals growing up, and more will only happen if a player is within this amount of chunks of it. Setting this lower and your view distance higher allows players to see further without using a ton of server performance. 

sync-chunk-writes: false

This is only relevant to servers not running Paper or PurPur, so feel free to skip it if you are on those server versions. By setting this to false, you are allowing the server to save chunks off the main thread of the CPU. This allows more room on your main tick loop for other things that cannot be moved off of it.

bukkit.yml

The bukkit.yml is included in every Bukkit, Spigot, Paper, and PurPur server. It is the original server software that allowed plugins to be added, and all the other popular server software that allows plugins are based on it. 

Spawn Limits

  • monsters: 20
  • animals: 5
  • water-animals: 2
  • water-ambient: 1
  • water-underground-creatures: 3
  • axolotls: 3
  • ambient: 1
This reduces the amount of mobs that will spawn your server. The higher the number the more mobs will spawn. Mobs are one of the largest causes of lag on Minecraft servers, so keeping these settings in-line will allow your server to lag less. We can use the "mob-spawn-range" setting in the spigot.yml to make it feel like there are more mobs even thought there are less than the vanilla settings. 

ticks-per

  • monster-spawns: 10
  • animals-spawns: 400
  • water-spawns: 400
  • water-ambient-spawns: 400
  • water-underground-create-spawns: 400
  • axolotl-spawns: 400
  • ambient-spawns: 400
This sets how often your server tries to spawn in mobs. The settings above should have a decent mix of allowing hostile mobs to still spawn while limiting passive mobs that need to spawn less, as many of them can be bred. 

spigot.yml

The spigot.yml file is on Spigot, Paper, and PurPur server. This is where you start getting into more lag reduction settings. 

view-distance: default

Changing this will overwrite the view-distance and simulation-distance in server.properties. There is no reason to do this, so it should be set to default. 

mob-spawn-range: 3

This reduces the amount of chunks in which mobs will spawn around players. Setting this lower will make it feel like there are more mobs spawning around players even if other settings have been reduced to lower mob counts. Mob spawn range should always be lower than your simulation distances in the server.properties file as well as lower than your hard despawn range in the paper.yml. 

entity-activation-range

  • animals: 16
  • monsters: 24
  • raiders: 48
  • misc: 8
  • water: 8
  • villagers: 16
  • flying-monsters: 48
This sets the distance away from a player a mob will start ticking/being active. It is worth noting that setting this too low can break some farms as well as make mobs unresponsive. However, it can have extreme performance benefits. The settings here are meant to reduce things as much as possible while keeping things working.

entity-tracking-range

  • animals: 16
  • monsters: 24
  • raiders: 48
  • misc: 8
  • water: 8
  • villagers: 16
  • flying-monsters: 48
This will set the distance in blocks from which entities will be visible. They just won't be set to players. Setting this too low can cause mobs to appear out of nowhere in view of the player. This should be set higher than your entity-activation-range in order to prevent this. 

tick-inactive-villagers: false

Villagers are extremely lag inducing. With that, setting this to false means that villagers will not be ticked outside of the entity-activation-range. This is a huge performance boost, but it can cause trading restocks and iron farms to have issues in some cases. 

nerf-spawner-mobs: true

This forces mobs that are from spawners not to have any AI when they spawn. They can be moved via water for spawners, but they will not attack players. This is an incredible performance boost on servers that have a lot of mob farms. 

merge-radius

  • item: 3.5
  • exp: 4.0
This defines the distance that items and XP orbs will be merged. This reduces the items on the ground thus preventing lag when chests are broken or a lot of items spawn. 

hopper-transfer: 8 

The time in ticks that hoppers will wait to move items. If hopers are causing lag on your server, this will help increase TPS. With that though, some hopper-based builds will/could be broken and no longer work. 

hopper-check: 8

The ticks between hoppers checking for an item above them. As with hopper-transfer, this will boost performance if you have a lot of hopper lag on your server. It can also break builds that rely on hoppers, though. 

paper.yml

Paper was a huge innovation when it comes to optimizing Minecraft server performance. Thus, from here on, there will be more settings to change. 

delay-chunk-unloads-by: 10s

This sets how long chunks stay loading after a player leaves. 10 seconds allows enough time for players to move back and forth quickly between chunks without issue while also ensuring chunks unload promptly when not in use.

max-auto-save-chunks-per-tick: 8

This slows down world saving by spreading it out over time. This gives better average performance. Move this higher if you have more than 20-30 players on your server at a time in order to avoid potential issues. 

prevent-moving-into-unloaded-chunks: true

This stops players from moving into unloaded chunks. By doing this, it stops players from queuing a ton of chunks and forcing additional lag on your server. Once a chunk loads, players will be able to move into without issue. 

entity-per-chunk-save-limit: 8

  • area_effect_cloud: 8
  • arrow: 16
  • dragon_fireball: 3
  • egg: 8
  • ender_pearl: 8
  • experience_bottle: 3
  • experience_orb: 16
  • eye_of_ender: 8
  • fireball: 8
  • firework_rocket: 8
  • llama_spit: 3
  • potion: 8
  • shulker_bullet: 8
  • small_fireball: 8
  • snowball: 8
  • spectral_arrow: 16
  • trident: 16
  • wither_skull: 4
This setting allows you to choose limits on the number of specific entities that can be saved within chunks. You can specify entity IDs, which can be found here. We recommend always limiting the entities above to prevent excess lag.

despawn-ranges

  • ambient:
    • hard: 56
    • soft: 30
  • axolotls:
    • hard: 56
    • soft: 30
  • creature:
    • hard: 56
    • soft: 30
  • misc:
    • hard: 56
    • soft: 30
  • monster:
    • hard: 56
    • soft: 30
  • underground_water_creature:
    • hard: 56
    • soft: 30
  • water_ambient:
    • hard: 56
    • soft: 30
  • water_creature:
    • hard: 56
    • soft: 30
This adjust the despawn range of entities in blocks. It is important to lower these values to clear mobs away from players quicker. The soft range should always be 30, and the hard range needs to be your simulation-distance in order to prevent mobs from instantly despawning in the view of the player. To calculate the hard despawn range, multiply your simulation distance by 16 and add 8 "(simulation-distance * 16) + 8". 

per-player-mob-spawns: true

Using this will create a more single-player like experience and prevent abuse from players who make mob farms and in turn use the entire mob cap. Technically, this can cause more lag depending on the players you have, but it makes things feel a lot more natural with all of the additional mob lag reduction settings we have implemented. 

max-entity-collisions: 2

This limits the amount of collisions one entity can have at a time. Setting this to 0 turns off all collisions even for players. 

update-pathfinding-on-block-update: false

Setting this to false means mobs will path find less increase before. 

fix-climbing-bypassing-cramming-rule: true

This prevents entities from piling up when climbing. This can be abused to cause lag if not enabled. 

armor-stands.tick: false

Setting this to false means armor stands won't be pushed by water or affected by gravity. In turn, they won't be ticking eating server resources. 

armor-stands.do-collision-entity-lookups: false

This stops armor stands from colliding. Again, a great way to prevent any lag coming from armor stands. 

tick-rates

📝 Note: if using PurPur, skip this setting.

  • behavior:
    • villager:
      • validatenearbypoi: 60
      • acquirepoi: 120
  • sensor:
    • villager:
      • secondarypoisensor: 80
      • nearestbedsensor: 80
      • villagerbabiessensor: 40
      • playersensor: 40
      • nearestlivingentitysensor: 40
With this, you can change villager behave in order to reduce the decisions they are making and the lag they are creating on the server. 

alt-item-despawn-rate

  • enabled: true
  • items:
    • cobblestone: 300
    • netherrack: 300
    • sand: 300
    • red_sand: 300
    • gravel: 300
    • dirt: 300
    • grass: 300
    • pumpkin: 300
    • melon_slice: 300
    • kelp: 300
    • bamboo: 300
    • sugar_cane: 300
    • twisting_vines: 300
    • weeping_vines: 300
    • oak_leaves: 300
    • spruce_leaves: 300
    • birch_leaves: 300
    • jungle_leaves: 300
    • acacia_leaves: 300
    • dark_oak_leaves: 300
    • mangrove_leaves: 300
    • cactus: 300
    • diorite: 300
    • granite: 300
    • andesite: 300
    • scaffolding: 600
Set different despawn times in ticks from the default world despawn time. Feel free to add any blocks you want here. Above are common blocks that are worth including on most servers. 

redstone-implementation: ALTERNATE_CURRENT

This improves how redstone works by using a method based off the Alternate Current mod. It can greatly improve the performance of redstone and the lag it will cause on your server. In some redstone builds, however, you may have issues. This is not the case most of the time, though. 

hopper.ignore-occluding-blocks: true

This setting determines whether hoppers will bypass containers inside solid blocks, such as a hopper minecart inside a sand or gravel block. Enabling this option may cause issues with builds that rely on this behavior. 

tick-rates.mob-spawner: 2

Sets how often mob spawners should tick to spawn new mobs. Increase this up to 5 in order to reduce lag from spawner mobs even more. 

optimize-explosions: true

Optimizes explosions with a better algorithm over vanilla thus reducing (and in some cases completely removing) lag from explosions. 

tick-rates.grass-spread: 4

Changes how fast grass spreads by increasing the amount of ticks it takes for grass to grow. This in turn gives a slight performance boost. 

non-player-arrow-despawn-rate: 20

How many ticks until arrows fired by mobs despawn.

creative-arrow-despawn-rate: 20 

How many ticks until arrows fired by players in creative despawn.

pufferfish.yml

This is technically a fork of Paper, but there is no reason to use it directly as PurPur has more customization and is forked from Pufferfish. I know that's confusing, so just know that if you have a PurPur server, you will have this server config file which we can use to reduce lag.

max-loads-per-projectile: 8

This sets the max amount of chunks that a projectile can load when it is fired. Changing this can help with projectiles from mobs loading unnecessary chunks, but it can cause issues with tridents and ender pearls. 

dab.enabled: true

This reduces how much an entity is ticked the further away it is from players. This can great a better experience for players without mobs having hard cutoffs in regards to entity activation. 

dab.max-tick-freq: 20

This sets the slowest amount entities that are farthest away from players will be ticked.

dab.activation-dist-mod: 7

Controls the gradient in which mobs are ticket. Lowering this makes DAB activate close to players, which in turn boosts performance.

enable-async-mob-spawning: true

This will reduce lag significantly by removing a lot of the computation used for mob spawning off the main server thread. For this to work, per-player-mob-spawning must be set to true in the paper.yml. 

enable-suffocation-optimization: true

Enabling this improves the suffocation check done on mobs.

inactive-goal-selector-throttle: true

This changes how entity AI selectors it's goal by making it update the goal every 20 ticks instead of every tick. This causes huge performance boosts while being nearly unnoticeable to players. 

disable-method-profiler: true

This disables some unneeded profiling that your server will do. Turning it off increases performance.

purpur.yml

PurPur is a fork of Paper and Pufferfish that adds even more lag optimization. One of the good things about PurPur, though, is that it is extremely customizable allowing you to get as much control over your settings and lag reduction as possible. 

use-alternate-keepalive: true

This will stop players who have poor connections to the server from lagging out as often. 

zombie.aggressive-towards-villager-when-lagging: false

If the server is lagging, this will make zombies stop attacking villagers. This can give a slight performance boost. 

entities-can-use-portals: false

When entities travel through portals, those chunks are loaded in the overworld. This stops this from happening and can stop random chunks from being loaded even when no players are around. 

dolphin.disable-treasure-searching: true

Stops dolphins from doing structure searches. 

🔗 Source: YouHaveTrouble Minecraft Optimization Guide

🌏 Pre-Generating Your World

While this isn't extremely important if you are using the config settings above, pre-generating your world can help reduce chunk lag. 

First things first, you will need to setup a world border. It in order to do this, go to your spawn location, and use the /worldborder set {diameter} command to set a world border. This must be done in order to generate your chunks. You can add to the world border in the future if you need to. 

Once you have setup your world border, you can use the plugin Chunky to generate all the chunks in your world. 

After Chunky has been installed, run the command /chunky worldborder, and then, use the /chunky start command to start generating your world. This will take a very long time depending on the size of your world. 

Was this article helpful?