FHttpServer (from UE4 module) can't be connected from outside.

I’ve created a little server based of UE4 FHttpServer class. Port 80.
And it kind of works. From running PC 127.0.0.1 can be opened in browser. But from other devices it can’t be reached.
I’ve opened all ports and port forwarding and tried other libraries which work successfully. But UE4 FHttpServer doesn’t.
Is this a bug? Do i need specific class settings?

Well looks like it is a bug. I’ve used another library and connection from outside worked.

It is not a bug, it is intentional. The server binds to the internal 127.0.0.1 interface, meaning it won’t accept external web requests. This is presumably to make sure that a game developed using the function doesn’t open up your computer to remote attack.

You can configure it to bind on any interface, thus serving requests from anywhere, by configuring the address “any:port”; you can also bind it to a particular interface with “address:port” (in which case “0.0.0.0:port” will also bind to “any” address, unless the parser/config code somehow rejects that.)

    Config = FHttpServerConfig::GetListenerConfig(ListenPort);
    if (0 == Config.BindAddress.Compare(TEXT("any"), ESearchCase::IgnoreCase))
    {
        BindAddress->SetAnyAddress();
    }

The HTTP server config has a default bind address:

GConfig->GetString(*IniSectionName, TEXT("DefaultBindAddress"), Config.BindAddress, GEngineIni);

and also an override per bound port, if you bind more than one:

			FParse::Value(*ListenerConfigStr, TEXT("BindAddress="), Config.BindAddress);
2 Likes