{"record":{"id":"d9a6f9c82d02a646","repo":"syncthing/syncthing","slug":"upnp-error-s-d-d9a6f9","errorCode":null,"errorMessage":"UPnP Error: %s (%d)","messagePattern":"UPnP Error: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/upnp/igd_service.go","lineNumber":211,"sourceCode":"\t\t<NewEnabled>1</NewEnabled>\n\t\t<NewPortMappingDescription>%s</NewPortMappingDescription>\n\t\t<NewLeaseDuration>%d</NewLeaseDuration>\n\t\t</u:AddPortMapping>`\n\tbody := fmt.Sprintf(template, s.URN, externalPort, protocol, internalPort, s.LocalIPv4, description, duration/time.Second)\n\n\tresponse, err := soapRequestWithIP(ctx, s.URL, s.URN, \"AddPortMapping\", body, &net.TCPAddr{IP: s.LocalIPv4})\n\tif err != nil && duration > 0 {\n\t\t// Try to repair error code 725 - OnlyPermanentLeasesSupported\n\t\tvar envelope soapErrorResponse\n\t\tif unmarshalErr := xml.Unmarshal(response, &envelope); unmarshalErr != nil {\n\t\t\treturn externalPort, unmarshalErr\n\t\t}\n\n\t\tif envelope.ErrorCode == 725 {\n\t\t\treturn s.AddPortMapping(ctx, protocol, internalPort, externalPort, description, 0)\n\t\t}\n\n\t\terr = fmt.Errorf(\"UPnP Error: %s (%d)\", envelope.ErrorDescription, envelope.ErrorCode)\n\t\tl.Debugf(\"Couldn't add port mapping for %s (external port %d -> internal port %d/%s): %s\", s.LocalIPv4, externalPort, internalPort, protocol, err)\n\t}\n\n\treturn externalPort, err\n}\n\n// DeletePortMapping deletes a port mapping from the specified IGD service.\nfunc (s *IGDService) DeletePortMapping(ctx context.Context, protocol nat.Protocol, externalPort int) error {\n\tconst template = `<u:DeletePortMapping xmlns:u=\"%s\">\n\t<NewRemoteHost></NewRemoteHost>\n\t<NewExternalPort>%d</NewExternalPort>\n\t<NewProtocol>%s</NewProtocol>\n\t</u:DeletePortMapping>`\n\n\tbody := fmt.Sprintf(template, s.URN, externalPort, protocol)\n\n\t_, err := soapRequest(ctx, s.URL, s.URN, \"DeletePortMapping\", body)\n\treturn err","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/syncthing/syncthing/blob/058bcd7334839663cf569501d3ac539034d45cb5/lib/upnp/igd_service.go#L193-L229","documentation":"The IGD gateway returned a SOAP fault for AddPortMapping that is not error 725 (which syncthing auto-repairs by retrying with a permanent lease). The gateway's own description and error code are embedded, e.g. 718 ConflictInMappingEntry, 727 ExternalPortOnlySupportsWildcard, 606 ActionNotAuthorized.","triggerScenarios":"IGDService.AddPortMapping with duration > 0 where the gateway rejects the mapping: another host already holds the external port (718), the router requires authorization (606), or the description/port parameters exceed what the device supports. Note the 725 path recursively retries with duration 0.","commonSituations":"Two devices behind the same router requesting the same external port; router UPnP table exhausted; ISP gateways with UPnP disabled/filtered (failure/606); conflicting static port-forward configured in the router admin UI.","solutions":["Match the error code: 718 → change to a different external port; 606 → enable UPnP or authorize the client in the router; 728 → reboot router to clear the full mapping table","Delete the conflicting static port-forward in the router admin UI, or pick a unique external port for this device","Set 'externalPort' in syncthing's config for the device instead of automatic discovery","Fall back to manual port forwarding and disable NAT discovery in syncthing if the gateway's UPnP is broken"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"extPort, err := svc.AddPortMapping(ctx, proto, intPort, extPort, desc, lease)\nif err != nil {\n    if strings.Contains(err.Error(), \"718\") { // ConflictInMappingEntry\n        // retry with a different external port\n    }\n    // else disable auto-mapping for this device and configure the forward manually\n}","preventionTips":["Assign each syncthing device behind a shared router a unique external port","Avoid mixing static router port-forwards with UPnP on the same port","Test UPnP health after router firmware upgrades before relying on automatic mapping"],"tags":["upnp","nat","network","port-mapping","router","go"],"backgroundTag":null,"analyzedSha":"058bcd7334839663cf569501d3ac539034d45cb5","analyzedAt":"2026-08-15T07:53:43.174Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}