Skip to content

Unexpected behaviour when mailserver DNS name does not exist #6792

@a1466d44-d3dc-4c0b-90c7-315b088731d7

Description

Steps To Reproduce

PS.: The reason this happened is that after a Server migration the mail server hostname changed!

  1. Edit ??/bwdata/env/global.override.env
  2. Set globalSettings__mail__smtp__host to a hostname that does not exist (anymore)
  3. Restart the server
  4. Go to /admin/
  5. Enter your mail address
  6. Now you get redirected to /login/ that responds with a HTTP 404 error

Expected Result

A roper error message that the mail server could not be reached.

Actual Result

You get redirected to /login/ that responds with a HTTP 404 error

Screenshots or Videos

2025-12-31T14:32:35.0077409+00:00 0HNI22UL95OQL:00000001 [INF] Executing endpoint '"Bit.Admin.Auth.Controllers.LoginController.Index (Admin)"' (500cc934)
2025-12-31T14:32:35.0078249+00:00 0HNI22UL95OQL:00000001 [INF] Route matched with "{action = \"Index\", controller = \"Login\"}". Executing controller action with signature "System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Index(Bit.Admin.Auth.Models.LoginModel)" on controller "Bit.Admin.Au
th.Controllers.LoginController" ("Admin"). (122b2fdf)
2025-12-31T14:32:35.0169538+00:00 0HNI22UL95OQL:00000001 [ERR] Unhandled exception (f80f533c)
System.Net.Sockets.SocketException (00000005, 0xFFFDFFFF): Name does not resolve
   at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, Nullable`1 startingTimestamp)
   at System.Net.Dns.<>c.<GetHostEntryOrAddressesCoreAsync>b__33_0(Object s, Int64 startingTimestamp)
   at System.Net.Dns.<>c__DisplayClass39_0`1.<RunAsync>b__0(Task <p0>, Object <p1>)
   at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, CancellationToken cancellationToken)
   at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, Int32 timeout, CancellationToken cancellationToken)
   at MailKit.MailService.ConnectNetworkAsync(String host, Int32 port, CancellationToken cancellationToken)
   at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken)
   at Bit.Core.Platform.Mail.Delivery.MailKitSmtpMailDeliveryService.SendEmailAsync(MailMessage message, CancellationToken cancellationToken) in /source/src/Core/Platform/Mail/Delivery/MailKitSmtpMailDeliveryService.cs:line 90
   at Bit.Core.Platform.Mail.Delivery.MailKitSmtpMailDeliveryService.SendEmailAsync(MailMessage message) in /source/src/Core/Platform/Mail/Delivery/MailKitSmtpMailDeliveryService.cs:line 45
   at Bit.Core.Services.Mail.HandlebarsMailService.SendPasswordlessSignInAsync(String returnUrl, String token, String email) in /source/src/Core/Platform/Mail/HandlebarsMailService.cs:line 538
   at Bit.Admin.Auth.IdentityServer.PasswordlessSignInManager`1.PasswordlessSignInAsync(String email, String returnUrl) in /source/src/Admin/Auth/IdentityServer/PasswordlessSignInManager.cs:line 37
   at Bit.Admin.Auth.Controllers.LoginController.Index(LoginModel model) in /source/src/Admin/Auth/Controllers/LoginController.cs:line 43
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-12-31T14:32:35.0173449+00:00 0HNI22UL95OQL:00000001 [INF] Executed action "Bit.Admin.Auth.Controllers.LoginController.Index (Admin)" in 9.4902ms (afa2e885)
2025-12-31T14:32:35.0174697+00:00 0HNI22UL95OQL:00000001 [INF] Executed endpoint '"Bit.Admin.Auth.Controllers.LoginController.Index (Admin)"' (99874f2b)
2025-12-31T14:32:35.0187592+00:00 0HNI22UL95OQL:00000001 [ERR] An unhandled exception has occurred while executing the request. (48a46595)
System.Net.Sockets.SocketException (00000005, 0xFFFDFFFF): Name does not resolve
   at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, Nullable`1 startingTimestamp)
   at System.Net.Dns.<>c.<GetHostEntryOrAddressesCoreAsync>b__33_0(Object s, Int64 startingTimestamp)
   at System.Net.Dns.<>c__DisplayClass39_0`1.<RunAsync>b__0(Task <p0>, Object <p1>)
   at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, CancellationToken cancellationToken)
   at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, Int32 timeout, CancellationToken cancellationToken)
   at MailKit.MailService.ConnectNetworkAsync(String host, Int32 port, CancellationToken cancellationToken)
   at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken)
   at Bit.Core.Platform.Mail.Delivery.MailKitSmtpMailDeliveryService.SendEmailAsync(MailMessage message, CancellationToken cancellationToken) in /source/src/Core/Platform/Mail/Delivery/MailKitSmtpMailDeliveryService.cs:line 90
   at Bit.Core.Platform.Mail.Delivery.MailKitSmtpMailDeliveryService.SendEmailAsync(MailMessage message) in /source/src/Core/Platform/Mail/Delivery/MailKitSmtpMailDeliveryService.cs:line 45
   at Bit.Core.Services.Mail.HandlebarsMailService.SendPasswordlessSignInAsync(String returnUrl, String token, String email) in /source/src/Core/Platform/Mail/HandlebarsMailService.cs:line 538
   at Bit.Admin.Auth.IdentityServer.PasswordlessSignInManager`1.PasswordlessSignInAsync(String email, String returnUrl) in /source/src/Admin/Auth/IdentityServer/PasswordlessSignInManager.cs:line 37
   at Bit.Admin.Auth.Controllers.LoginController.Index(LoginModel model) in /source/src/Admin/Auth/Controllers/LoginController.cs:line 43
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
2025-12-31T14:32:35.0188565+00:00 0HNI22UL95OQL:00000001 [INF] Executing endpoint '"Bit.Admin.Controllers.ErrorController.Error (Admin)"' (500cc934)
2025-12-31T14:32:35.0188840+00:00 0HNI22UL95OQL:00000001 [INF] Route matched with "{action = \"Error\", controller = \"Error\"}". Executing controller action with signature "Microsoft.AspNetCore.Mvc.IActionResult Error(System.Nullable`1[System.Int32])" on controller "Bit.Admin.Controllers.ErrorController" ("Adm
in"). (122b2fdf)

Additional Context

As stated above this Issue just arose due to a server upgrade where the new mail server got a new hostname. And as you normally don't login to the /admin Page that often, this this just occurred almost a month later to me.

Build Version

2025.12.0

Environment

Self-Hosted

Environment Details

  • Operating System: Debian 13
  • CPU: Intel Xeon CPU E3-1226
  • RAM: 16G
  • Filesystem used: ZFS
  • Docker version 26.1.5+dfsg1, build a72d7cd

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions