The message
java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/screens/Screen for invalid dist DEDICATED_SERVER
java.lang.RuntimeException: Cannot load class net.minecraft.client.MinecraftClient in environment type SERVERThe full message is in the game folder: logs/latest.log for every start, and crash-reports/ for crashes that got far enough to write a report. In Prism, CurseForge and the Modrinth App, the instance's folder button opens the game folder.
What it means
Some mods only change what you see: menus, minimaps, shaders, sounds, zoom. They use code that exists only in the game client. A dedicated server has no client code, so when such a mod tries to load it, the server stops.
Forge and NeoForge say “invalid dist DEDICATED_SERVER”; Fabric and Quilt say “in environment type SERVER”. The class named after it, under net/minecraft/client, is the client code the mod reached for.
It usually happens after copying a whole modpack's mods folder from a PC to a server.
How to fix it
- 1Look in the crash report or logs/latest.log below the error for the first line that names a mod's package (not net.minecraft). That is usually the mod.
- 2Check the mod's page: Modrinth and CurseForge mark mods as client-side, server-side or both.
- 3Remove that mod from the server's mods folder only. Players can keep it in their own game.
- 4Start the server again. If it stops with the same error, another client-only mod is still there: repeat.
With Packquill
Packquill recognises this crash and says that a client-only mod is running on a server (or a server-only one in the game). In the Add tab, the client or server filter shows only mods made for the side you need.
Packquill is free for Windows and Linux. It backs up every change, so anything it does can be undone.
Questions
Do players need to remove the mod too?
No. Client-only mods work in the player's own game and are not needed on the server.
Why did it work in single player?
Single player runs both the client and a built-in server in one game, so client code is always there. A dedicated server has none.