HttpServerService
Creates a bounded HTTP server with explicit routes and lifecycle.
Required setup
Section titled “Required setup”network.server; the native SDK supplies the server transport. Bind to loopback for local-only examples.
The host is the program running your Luau code: normally the SDK’s native runner. Its provider/adapter implements an optional service. You do not need to write one to use a service already supplied by the SDK. Capabilities explains the manifest and remaining platform limits.
Example
Section titled “Example”Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.
Project setup: add network.server to Capabilities in lui.json. See the capability guide.
local Window = Instance.new("Window", { Title = "LUI example", Size = UDim2.fromOffset(560, 280),})local Status = Instance.new("TextLabel", { Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170), Size = UDim2.new(1, -32, 0, 72),})local Server = app:GetService("HttpServerService"):CreateServer({Address = "loopback", Port = 0})Server:Route("GET", "/status", function(Request) return {StatusCode = 200, Headers = {{Name = "Content-Type", Value = "text/plain"}}, Body = "Ready: " .. Request.Path}end)Server:Start()Status.Text = "Local URL: http://127.0.0.1:" .. Server.Port .. "/status"Window.Destroying:Connect(function() Server:Close() end)Window.Visible = trueExpected result: Starts an HTTP endpoint on a free local-only port. Open the displayed URL on this machine to see Ready: /status.
For source, manifest, pin and assets together, use the complete practical recipe.
Methods
Section titled “Methods”CreateServer
Section titled “CreateServer”Creates and binds a server. Register Route handlers, then call Start. A server is not internet-accessible merely because you created it; binding and host policy determine reachability.
CreateServer(Options: HttpServerOptions) -> HttpServerFull type declaration — for type checking and deeper reference
The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.
export type HttpServerService = { read CreateServer: (Self: HttpServerService, Options: HttpServerOptions) -> HttpServer,}Availability and deeper reading
Section titled “Availability and deeper reading”See platform limits before relying on host-specific behavior. The framework design specification and reflection/type sources are deeper engineering references, not extra setup required to build an app.