Setting Up a UE4 Project for Dedicated Server

Ready to build your game's dedicated server? Whoa there buddy. We have some work to do before you can.

Before you start down the road of following this guide make sure you have ~130GB free storage for the engine.

  1. Download UnrealEngine from GitHub. If you don't have access to this then go and follow this guide.
    You can either download the zip (release) or do a git clone.
  2. Go into the directory where you downloaded the engine and run Setup.bat.
  3. Run GenerateProjectFiles.bat and then open UE4.sln.
  4. Select Development Editor, Win64, and UE4 then press Local Windows Debugger (or Debug -> Start Debugging or Build -> Build Solution). This will take a while (~40 minutes) so just let it do its thing.
  5. After it's completed the project selector will show up (if you had no errors) and then you can just close the editor and Visual Studio.
  6. Go to your project and right click your uproject (Switch Unreal Engine version) then select the Source build.
  7. Create a Server and Client target.cs file.

    The Client.Target.cs file will look similar to: (download example ExampleProjectClient.Target.cs)
    using UnrealBuildTool;
    
    using System.Collections.Generic;
    
    

    public class ExampleProjectClientTarget : TargetRules { public ExampleProjectClientTarget(TargetInfo Target) : base(Target) { Type = TargetType.Client; DefaultBuildSettings = BuildSettingsVersion.V2; ExtraModuleNames.Add(“ExampleProject”); } }

    The Server.Target.cs file will look similar to: (download example ExampleProjectServer.Target.cs)
    using UnrealBuildTool;
    
    using System.Collections.Generic;
    
    

    public class ExampleProjectServerTarget : TargetRules { public ExampleProjectServerTarget(TargetInfo Target) : base(Target) { Type = TargetType.Server; DefaultBuildSettings = BuildSettingsVersion.V2; ExtraModuleNames.Add(“ExampleProject”); } }

     

  8. Check out my guide on using Unreal Frontend.
  9. In Unreal Frontend select PlatformServer and PlatformClient. You don't need PlatformNoEditor etc. (By using Client builds it removes unnecessary code that allows listen servers.) Also, your Unreal Frontend should be from your Source build not binary build from the launcher. (as from the photo above my Source build is in D:\dev\UnrealEngine so my UF is D:\dev\UnrealEngine\Engine\Binaries\Win64.)
  10. Just build your project like the UF guide.
  11. If you're not using Sessions, Steam, or any other third party to handle connections you can connect to the dedicated server by doing open <ip> in the console in your Client.exe. If you're in Shipping build then the console is disabled so you'd need to do a server browser or even a button on your main menu etc to execute a console command.
  12. Once the project has been built you can boot up the Server.exe -log  or you can put it on a VPS or Dedicated server etc and boot it from there.

    In other words, zip up the WindowsServer (or whateverServer) and put that on your server to boot if you want other players to connect. (or you could port forward etc)

 

Using server without building binaries (for development or debugging)

Server.bat

@echo off

"Path\To\UE4Editor.exe" "Path\To\My\Project.uproject" -log -server

Client.bat

@echo off

"Path\To\UE4Editor.exe" "Path\To\My\Project.uproject" -log -game -windowed -ResX=1080 -ResY=720

 

 

until next time