How do I enable command blocks on my Minecraft server?
In this article
Command blocks run commands automatically: teleporters, shops, minigame logic, welcome messages, timers. Up to Java 1.21.8 they were disabled on a server by default and you enabled them in server.properties. Since 1.21.9 this is a gamerule that is on by default in a new world and can be switched without a restart. Handle them with care: a command block runs with full operator rights and a mistake in one can wreck a world. Enabling them takes one setting; using them safely takes a little more.
Enabling command blocks
Java 1.21.11 and newer (including 26.x): type gamerule command_blocks_work true in the console. On Java 1.21.9 and 1.21.10 the same rule is called commandBlocksEnabled (gamerule commandBlocksEnabled true). No restart is needed; turn it off with false, and gamerule command_blocks_work without a value shows the current state. The enable-command-block key in server.properties no longer exists on these versions. On Bedrock the rule is called commandblocksenabled. Every gamerule with its old and new name is listed in our overview of Minecraft gamerules and commands.
Java 1.21.8 and older:
- Go to the game panel and click your server.
- Open the Properties page and set ENABLE-COMMAND-BLOCK to yes. Prefer the file? Then set
enable-command-block=trueinserver.propertiesthrough File Manager. - Save and restart the server. This setting is only read at start-up.
Getting a command block
Command blocks are not in the creative inventory. As an operator, give yourself one with /give @s command_block (or from the console: give PlayerName command_block). The chain and repeating variants: chain_command_block and repeating_command_block. You need OP level 2 or higher to place and edit them; see how do I OP myself.
The three types
- Impulse (orange): runs the command once each time it receives a redstone signal.
- Chain (green): runs after the command block it is pointing away from has run; used to link several commands.
- Repeating (purple): runs the command every tick (20 times per second) while powered; set Always Active to run without redstone.
A first example
Place an impulse command block, right-click it and type tp @p 0 100 0. Put a button on it and press: the nearest player is teleported to the coordinates. For a welcome message, use a repeating block with title @a[distance=..3] actionbar "Welcome!"; players within three blocks see the text. Commands in a command block are typed without a leading slash.
Common mistakes
- "Command blocks are disabled on this server" when opening one: the setting is still off (on 1.21.9 and newer: the gamerule above), or on 1.21.8 and older the server was not restarted.
- Nothing happens: check the block's output with Previous output in the interface; it shows the error the command produced. Selectors such as
@pneed a player in range. - The block keeps spamming the console: set
gamerule command_block_output false(before 1.21.11:commandBlockOutput) to hide the messages, andgamerule send_command_feedback false(before 1.21.11:sendCommandFeedback) for the chat feedback. - Repeating block stops after a restart: it must be in a chunk that stays loaded; use a spawn chunk or force-load the chunk with
/forceload add. - Players can edit command blocks: only operators of level 2+ can. If a player can, they have OP; remove it.
Safer alternatives
Command blocks are fine for a small server you run yourself. For anything staff or players interact with, a plugin is usually safer and easier: EssentialsX for warps and kits, a datapack for logic that should stay in the world, or a scripting plugin such as Skript for custom behaviour. Those do not require operator rights for every action.
Stuck, for example with a command that works in chat but not in the block? Open a ticket and include the command and the Previous output text.
Launch your server in 60 seconds on our own hardware.