Open the world to LAN
/publishShares the world on your local network and shows the port in the chat.

/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.
/publish [<allowCommands> [<port>]]// Only in single player: the command does not exist on a dedicated server.
| Argument | Expects | What it does |
|---|---|---|
| allowCommandsoptional | true / false | true gives other players cheats, false keeps commands away from them. |
| portoptional | Whole number0 to 65,535 | Network port from 0 to 65535, for example 25565; leave it out to let the game pick one. |
/publishShares the world on your local network and shows the port in the chat.
/publish true 25565Other players get cheats and connect on port 25565.
Fill in the fields, then copy the command.
Command generator/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
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.
Your world is already open, on the port shown in the message. Run /unpublish first if you want other settings.
Type it in a single-player world with cheats on: /publish [<allowCommands> [<port>]]. It does not exist on a dedicated server.
Single player with cheats on, level 4. Only in single player: the command does not exist on a dedicated server.