- ABP Framework version: v8.2.0
- UI Type: MVC
- Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
- **Tiered: yes
- Exception message and full stack trace:
- An unhandled exception occurred while processing the request. SocketException: No connection could be made because the target machine actively refused it.
System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(short token) HttpRequestException: No connection could be made because the target machine actively refused it. (localhost:44371)
System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(string host, int port, HttpRequestMessage initialRequest, bool async, CancellationToken cancellationToken) IOException: IDX20804: Unable to retrieve document from: 'https://localhost:44371/.well-known/openid-configuration'.
Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)
InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://localhost:44371/.well-known/openid-configuration'. Will retry at '7/31/2025 7:50:28 AM +00:00'. Exception: 'System.IO.IOException: IDX20804: Unable to retrieve document from: 'https://localhost:44371/.well-known/openid-configuration'.
---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (localhost:44371)
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.InjectNewHttp11ConnectionAsync(QueueItem queueItem)
at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionWaiter
1.WaitForConnectionWithTelemetryAsync(HttpRequestMessage request, HttpConnectionPool pool, Boolean async, CancellationToken requestCancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.SendAndRetryOnNetworkErrorAsync(HttpClient httpClient, Uri uri)
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)'.
Microsoft.IdentityModel.Protocols.ConfigurationManager
- Steps to reproduce the issue:
- Prepare a tiered solution with parameters specified above. Configure the .api.host and .web projects for startup
1 Answer(s)
-
1
The error
No connection could be made because the target machine actively refused it. (localhost:44371)
indicates that your application is trying to connect to an OpenID Connect authority athttps://localhost:44371/.well-known/openid-configuration
, but nothing is running on that address/port.In a tiered ABP solution, the
.Web
and.HttpApi.Host
projects typically use the.AuthServer
project as the OpenID Connect authority. If the.AuthServer
is not running, or if theAuthority
URL in your configuration points to the wrong address, you will get this error.
How to fix:
Start the AuthServer
- Ensure the
.AuthServer
project is running and accessible at the URL specified in your configuration (e.g.,https://localhost:44371
).
- Ensure the
Check Configuration
- In your
.Web
and.HttpApi.Host
projects, verify theAuthServer:Authority
setting inappsettings.json
orappsettings.Development.json
:
- In your
"AuthServer": { "Authority": "https://localhost:44371", "RequireHttpsMetadata": "false" }
- Make sure this matches the actual running URL of your
.AuthServer
project.
Check Launch Settings
- In
Properties/launchSettings.json
of the.AuthServer
project, confirm the application is set to launch on the correct port (44371).
- In
Run All Projects
- When developing locally, you must run the
.AuthServer
,.HttpApi.Host
, and.Web
projects simultaneously. If using Visual Studio, set them all as startup projects.
- When developing locally, you must run the
Firewall/Port Conflicts
- Ensure no firewall or other application is blocking port 44371.
Production/Containerized Environments
- If deploying, ensure the
Authority
URL is set to the deployed AuthServer's public address, notlocalhost
.
- If deploying, ensure the
Summary:
This error is caused by the.Web
or.HttpApi.Host
project being unable to reach the.AuthServer
at the configured URL. Make sure the AuthServer is running and the configuration matches its actual address.No validated source available for this specific query.
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.