{"record":{"id":"22c878393646f996","repo":"egametang/ET","slug":"cmd-netsh-http-add-urlacl-url-http-ad","errorCode":null,"errorMessage":"请先在cmd中运行: netsh http add urlacl url=http://*:你的address中的端口/ user=Everyone, address: {address}","messagePattern":"请先在cmd中运行: netsh http add urlacl url=http://\\*:你的address中的端口/ user=Everyone, address: (.+?)","errorType":"http","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.http/Scripts/Hotfix/Server/HttpComponentSystem.cs","lineNumber":32,"sourceCode":"            {\n                self.Listener = new HttpListener();\n\n                foreach (string s in address.Split(';'))\n                {\n                    if (s.Trim() == \"\")\n                    {\n                        continue;\n                    }\n                    self.Listener.Prefixes.Add(s);\n                }\n\n                self.Listener.Start();\n\n                self.Accept().Coroutine();\n            }\n            catch (HttpListenerException e)\n            {\n                throw new Exception($\"请先在cmd中运行: netsh http add urlacl url=http://*:你的address中的端口/ user=Everyone, address: {address}\", e);\n            }\n        }\n        \n        [EntitySystem]\n        private static void Destroy(this HttpComponent self)\n        {\n            if (self.Listener == null)\n            {\n                return;\n            }\n            try\n            {\n                if (self.Listener.IsListening)\n                {\n                    self.Listener.Stop();\n                }\n            }\n            catch (Exception)","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.http/Scripts/Hotfix/Server/HttpComponentSystem.cs#L14-L50","documentation":"HttpComponentSystem.Awake (line 32) catches HttpListenerException from HttpListener.Start() and rethrows a guidance Exception telling the operator to register a URL reservation via netsh. HttpListener throws this when the process lacks permission for the configured prefix, the prefix/port is invalid or already bound, or the host wildcard requires admin/urlacl.","triggerScenarios":"self.Listener.Start() on Windows where no urlacl grants the user the http://+:port/ prefix, a port already in use, a malformed prefix string, or running as non-admin without the reservation.","commonSituations":"First run of an HTTP server process on a fresh machine, switching the bind address/port, running the server as a non-privileged service account, port conflict with another process, prefix missing the trailing slash.","solutions":["Run the documented netsh command as admin: netsh http add urlacl url=http://*:PORT/ user=Everyone (replace PORT with the value in the address string).","Confirm the port is free: netstat -ano | findstr :PORT.","Ensure the prefix string is well-formed (scheme + host + trailing slash) and uses the same form as the urlacl.","Run the server under an account that has the reservation, or reserve for the specific account instead of Everyone.","On stop, also run netsh http delete urlacl url=... to clean up."],"exampleFix":"// before (prefix must match urlacl exactly)\nhttp://+:8080/\n\nrem after: register reservation as admin\nnetsh http add urlacl url=http://+:8080/ user=Everyone\nnetsh http add urlacl url=http://*:8080/ user=Everyone","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* Awake binds HttpListener */ }\ncatch (HttpListenerException e) { Log.Error($\"http bind failed (needs urlacl): {e.Message}\"); throw; }","preventionTips":["Pre-register urlacl via netsh as part of deployment.","Verify the port is unused before start.","Run under an account that owns the reservation.","Keep the prefix string identical to the urlacl (incl. trailing slash and host wildcard)."],"tags":["http","windows","netsh","permissions","network"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}