First, decide whether you want to start a "Host & Play" multiplayer game or a dedicated server game. The Host & Play option allows you to create a temporary server to play on while you are online and your friends can enter your world. When you turn off the game, the server will close and save the game experience, if you want to start the server again, you need to start the game through Host & Play. If you want to create an autonomous server where players can access the game without your presence on the server, you can create a dedicated server. Such a server will not be located on your device, so it will work regardless of whether you are playing or not.
Setting up a "Host & Play" server
This is the easiest way to play multiplayer and is well suited for home LAN or short online cooperative games. Launch Terraria and select Multiplayer from the main menu, then Host & Play. Select a world to play in (or create a new one) and enter a password (or leave the field blank if you do not want to use a password).
For the first start of your server, you don't need to worry about the configuration file, as the Terraria server file has a great multi-step wizard to get you up and running quickly
The files for the dedicated server are located in the Terraria files folder. Example for Steam: C:\Program Files (x86)\Steam\steamapps\common\Terraria
First, try setting up the server without the configuration file. To do this, locate the folder where Terraria is installed, find the TerrariaServer.exe file and run it.
A window with the server management interface opens. Here you can enter commands or view information. At startup, you will be prompted to select a world, after which a list of worlds available on your computer will appear. The window also allows you to create or delete worlds at startup. When creating a new world, follow the instructions in the window to change certain aspects of the world generation.
By default, Terraria saves all worlds to the folder "C:\Users\UserName\Documents\MyGames\Terraria\Worlds"
Setting up a dedicated server using a configuration file
To start the server with a ready-made configuration file, you need to find the Terraria installation folder and then run "TerrariaServer.exe -conig <serverconfigfile>", where <serverconfigfile> is the configuration file.
Use cmd (console) to navigate to the Terraria folder and type "TerrariaServer.exe -config <serverconfigfile>" without the quotes, then press Enter.
Make a shortcut to "TerrariaServer.exe", right-click on it, select Properties, edit the Target field (in the original: "<...>\TerrariaServer.exe"), enter the following at the end, after "TerrariaServer.exe": "-config <serverconfigfile>" without quotes (it is important to leave a space between ".exe" and "-config").
If you want, you can create a batch file, which is the same as a shortcut in function. First, you create a new text file (.txt), then edit it in any simple editor (not Office, something like Notepad), and then enter commands like this:
@echo off cls TerrariaServer.exe -config <configuration file
When you're done, save this file in the new .bat format instead of .txt.