TechnitiumSoftware/DnsServer · error · DnsServerException
DNS application already exists: {applicationName}
Error message
DNS application already exists: {applicationName} What it means
Thrown by InstallApplicationAsync when an entry for the given applicationName already exists in the in-memory _applications dictionary. The DNS server treats each installed application (DNS App) as uniquely named; a duplicate name is rejected before any filesystem write so the existing install is not corrupted.
Source
Thrown at DnsServerCore/Dns/Applications/DnsApplicationManager.cs:375
}
}));
}
await Task.WhenAll(tasks);
RefreshAppObjectLists();
}
public async Task<DnsApplication> InstallApplicationAsync(string applicationName, Stream appZipStream)
{
foreach (char invalidChar in Path.GetInvalidFileNameChars())
{
if (applicationName.Contains(invalidChar))
throw new DnsServerException("The application name contains an invalid character: " + invalidChar);
}
if (_applications.ContainsKey(applicationName))
throw new DnsServerException("DNS application already exists: " + applicationName);
string applicationFolder = Path.GetFullPath(Path.Combine(_appsPath, applicationName));
if (!applicationFolder.StartsWith(_appsPath + Path.DirectorySeparatorChar))
throw new DnsServerException("The application name is invalid: " + applicationName);
if (Directory.Exists(applicationFolder))
Directory.Delete(applicationFolder, true);
Directory.CreateDirectory(applicationFolder);
//keep a copy of the zip file in the application folder for transferring to other nodes
await using (FileStream zipCopyStream = new FileStream(Path.Combine(applicationFolder, applicationName + ".zip"), FileMode.Create, FileAccess.ReadWrite))
{
await appZipStream.CopyToAsync(zipCopyStream);
zipCopyStream.Position = 0;
await using (ZipArchive appZip = new ZipArchive(zipCopyStream, ZipArchiveMode.Read, false, Encoding.UTF8))View on GitHub (pinned to d0484b6c1e)
Solutions
- If you want to replace the app, call UpdateApplicationAsync(name, zipStream) instead of InstallApplicationAsync.
- Call UninstallApplicationAsync(name) first, then InstallApplicationAsync.
- Check DnsApplicationManager (or the apps API listing) before installing and skip when the name is already present.
- Restart the server if you suspect _applications is stale relative to disk (e.g. directory was manually removed).
Example fix
// before
await appManager.InstallApplicationAsync(name, zip);
// after
if (appManager.ListApplications().Any(a => a.Name == name))
await appManager.UpdateApplicationAsync(name, zip);
else
await appManager.InstallApplicationAsync(name, zip); Defensive patterns
Strategy: validation
Validate before calling
bool AppExists(IApplicationManager mgr, string name) => mgr.ListApplications().Any(a => a.Name == name); // call: if (AppExists(mgr, name)) await mgr.UpdateApplicationAsync(name, zip); else await mgr.InstallApplicationAsync(name, zip);
Try / catch
try { await mgr.InstallApplicationAsync(name, zip); }
catch (DnsServerException ex) when (ex.Message.Contains("already exists")) { await mgr.UpdateApplicationAsync(name, zip); } Prevention
- Branch on existence: update if present, install if absent.
- Drive app deploys through a single install-or-update helper to avoid duplicate-install calls.
- Treat applicationName as an immutable key per app.
When it happens
Trigger: Calling InstallApplicationAsync(name, zipStream) twice with the same name without first calling UninstallApplicationAsync. Or an automated/HA node re-running install after the dictionary was populated from a previously synced app folder on startup.
Common situations: Re-uploading a zip through the web UI thinking it will 'upgrade'; scripting node-to-node app replication that calls install instead of update; a half-uninstalled app whose directory was deleted but whose entry was retained (rare).
Related errors
- Failed to update web server config. Please try again.
- User already exists: {username}
- User already exists: {newUsername}
- Group already exists: {name}
- Group already exists: {newGroupName}
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/458cac36032362ef.
Report an issue: GitHub.