News
Game
Guides
Downloads
Versions
/publish
COMMANDS SERVER ADMIN CONSOLE · LEVEL 4 Added in 1.14 or earlier

/publish command in Minecraft

/publish opens your singleplayer world to other players on your local network, like the Open to LAN button in the pause menu. You can choose whether other players get cheats and which port to use. It needs level 4, so cheats must be on in your world.

Syntax

/publish [<allowCommands> [<port>]]

// Only in single player: the command does not exist on a dedicated server.

ArgumentExpectsWhat it does
allowCommandsoptionaltrue / falsetrue gives other players cheats, false keeps commands away from them.
portoptionalWhole number0 to 65,535Network port from 0 to 65535, for example 25565; leave it out to let the game pick one.
All 3 forms
  • /publish
  • /publish <allowCommands>
  • /publish <allowCommands> <port>

Examples

Open the world to LAN

/publish

Shares the world on your local network and shows the port in the chat.

Java 26.3

Open with cheats on a chosen port

/publish true 25565

Other players get cheats and connect on port 25565.

Java 26.3
Build your command

Fill in the fields, then copy the command.

Command generator

Arguments

/publish true gives other players cheats, /publish false does not. Add a port number to pick it yourself, for example /publish true 25565. The game confirms with Local game hosted on port 25565, and friends on the same network then find the world in their Multiplayer list.

The command only exists in singleplayer, not on a dedicated server. To close the world again without leaving it, use /unpublish. A guest who causes trouble can be removed with /kick.

✓ Checked in Java Edition 26.3 · updated 2 November 2026

/publish: FAQ

Which port should I choose?

Any free port works; the LAN screen accepts numbers from 1024 to 65535. If you leave the port out, the game picks one and shows it in the chat.

Why does /publish say the game is already hosted?

Your world is already open, on the port shown in the message. Run /unpublish first if you want other settings.

How do I use /publish?

Type it in a single-player world with cheats on: /publish [<allowCommands> [<port>]]. It does not exist on a dedicated server.

Who can use /publish?

Single player with cheats on, level 4. Only in single player: the command does not exist on a dedicated server.

Related commands