I'm running a .net core application in a windows container where it uses AWS SDK to connect to ClouldWatch. I have used Serilog.Sink.AWSCloudWatch for this integration.
CloudWatch integration works when I run it from my host machine however I'm getting below exception when I tried that from a windows docker container. As I am new to dockers, would you be able to help me to solve this issue.
Error initializing log stream. No logs will be sent to AWS CloudWatch. Exception was System.Net.Http.HttpRequestException: No such host is known.
---> System.Net.Sockets.SocketException (11001): No such host is known.
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
at Serilog.Sinks.AwsCloudWatch.CloudWatchLogSink.CreateLogGroupAsync()
at Serilog.Sinks.AwsCloudWatch.CloudWatchLogSink.EnsureInitializedAsync()
at Serilog.Sinks.AwsCloudWatch.CloudWatchLogSink.EmitBatchAsync(IEnumerable`1 events).
Docker file,
ROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-1903 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1903 AS build
WORKDIR /src
COPY *.sln .
COPY MyProject/*.csproj ./MyProject/
RUN dotnet restore
# copy full solution over
COPY . .
RUN dotnet build
FROM build AS release
WORKDIR "/src/MyProject"
RUN dotnet build "MyProject.csproj" -c Release -o /app/build
FROM build AS publish
WORKDIR "/src/MyProject"
RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /Users/ContainerUser/.aws
COPY credentials .
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.dll"]
Thanks
Actual issue was I was running the application with vpn on, so https request was rejected by the vpn. I managed to solve this without vpn.
Related
I recently launched a Blazor Server application on a Debian 11 server. The application is running through a Linux Docker container. I have used a DNS to connect my domain name to my server, and am trying to get an SSL certificate applied to my domain for my Blazor app.
By following Certbot guides, I have done the following on my Debian 11 server where my Blazor container is hosted to port 80:
apt-get install cerbot
certbot certonly --standalone
And I got the following message:
Congratulations!
Your certificate and chain have been saved at: /etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at: /etc/letsencrypt/live/example.com/privkey.pem
My site is still not using https. I cannot find any other instructions to apply the SSL from this point. Do I need to add code to my Blazor Server app to point to the SSL files? Do I need to mount the SSL files to somewhere in my Docker container? Thanks.
Update: I have been running my Docker container with the following command. I've tested the mounting of my keys folder and can see it is correct, but I still have issues when launching the container. It appears to be unable to find the keys even though they are mounted to the container correctly:
docker run -p 80:80 -p 443:443 -v /etc/letsencrypt/live/example.com:/https/ -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=443 -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/fullchain.pem -e ASPNETCORE_Kestrel__Certificates__Default__KeyPath=/https/privkey.pem --restart always --name blazorserver blazorserver:1.01
I get these terminal errors, resulting in Program.cs failing to run app.Run();
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {c9ce4f00-c893-456c-b894-6421bf21ffd8} may be persisted to storage in unencrypted form.
Unhandled exception. System.IO.FileNotFoundException: Could not find file '/https/fullchain.pem'.
File name: '/https/fullchain.pem'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Func`4 createOpenException)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.File.ReadAllText(String path, Encoding encoding)
at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.ImportFromPemFile(String certPemFilePath)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Program.<Main>$(String[] args) in /src/Program.cs:line 36
So, the issue was that the /etc/letsencrypt/live/example.com/fullchain.pem file needs access to other files in the /etc/letsencrypt hierarchy. After mounting the entire /etc/letsencrypt directory to /https, I was able to access the SSL files with the full path, e.g. /https/live/example.com/fullchain.pem for the __Path variable.
Hopefully somebody finds my troubleshooting useful, as I could not find much information out there for Let's Encrypt SSL setup for Kestrel and/or Blazor.
I have a subdomain which must redirect any route to a main domain root:
http(s)://subdomain.example.com/ => https://example.com
http(s)://subdomain.example.com/{*anything} => https://example.com
So, I have created a minimal .NET 6 web app:
using System.Net;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpsRedirection(options =>
{
options.RedirectStatusCode = (int)HttpStatusCode.PermanentRedirect;
options.HttpsPort = 443;
});
WebApplication app = builder.Build();
app.Urls.Add("http://+");
app.Urls.Add("https://+");
app.UseHttpsRedirection();
app.MapGet("/", () => Results.Redirect("https://example.com", true, true));
app.MapGet("/{*_}", (string _) => Results.Redirect("https://example.com", true, true));
app.Run();
When I run it locally, everything works:
http://localhost redirects to https://example.com
http://localhost/blah redirects to https://example.com
https://localhost redirects to https://example.com
https://localhost/blah redirects to https://example.com
Then I created App Service (Linux) in Azure for which:
I set up my custom domain subdomain.example.com
I added App Service Managed certificate for my custom subdomain
HTTPS only is ON
Looks good so far. But when I deploy my app and run it, 2 problems:
opening https://mycustomapp.azurewebsites.net shows me This site has been reported as unsafe (!)
when open http(s)://subdomain.example.com I get application error
And here's what I see in the logs:
2022-06-03T03:43:22.170878337Z ASP .NETCore Version: 6.0.3
2022-06-03T03:43:22.170881637Z Note: Any data outside '/home' is not persisted
2022-06-03T03:43:22.462209593Z Running oryx create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand 'dotnet PermanentRedirectMinimal.dll'
2022-06-03T03:43:22.553430350Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2022-06-03T03:43:22.553445850Z Could not find operation ID in manifest. Generating an operation id...
2022-06-03T03:43:22.553843654Z Build Operation ID: [guid]
2022-06-03T03:43:23.236717018Z
2022-06-03T03:43:23.237393225Z Agent extension
2022-06-03T03:43:23.237407225Z Before if loop >> DotNet Runtime
2022-06-03T03:43:23.277833149Z DotNet Runtime 6.0Writing output script to '/opt/startup/startup.sh'
2022-06-03T03:43:23.358910299Z Running user provided startup command...
2022-06-03T03:43:25.470314040Z Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
2022-06-03T03:43:25.470359841Z To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
2022-06-03T03:43:25.470366541Z For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
2022-06-03T03:43:25.470370941Z at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
2022-06-03T03:43:25.470375241Z at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
2022-06-03T03:43:25.470379341Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
2022-06-03T03:43:25.470383541Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken)
2022-06-03T03:43:25.470387541Z at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
2022-06-03T03:43:25.470402041Z at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
2022-06-03T03:43:25.470405941Z at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
2022-06-03T03:43:25.470409541Z at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2022-06-03T03:43:25.470413041Z at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2022-06-03T03:43:25.470416641Z at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2022-06-03T03:43:25.470426442Z at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
2022-06-03T03:43:25.470430142Z at Microsoft.AspNetCore.Builder.WebApplication.Run(String url)
2022-06-03T03:43:25.472178560Z at Program.$(String[] args) in e:...\PermanentRedirectMinimal\Program.cs:line 22 [ ==> where app.Run() is ]
2022-06-03T03:43:41.244915770Z Could not open output /home/logs/dumps/coredump.d26e6752ab2d.36.1654227802: 2 No such file or directory
2022-06-03T03:43:41.253765645Z Gathering state for process 36 dotnet
2022-06-03T03:43:41.253793945Z Crashing thread 00000024 signal 00000006
2022-06-03T03:43:41.253799545Z Writing minidump with heap to file /home/logs/dumps/coredump.d26e6752ab2d.36.1654227802
2022-06-03T03:43:41.762563322Z /opt/startup/startup.sh: line 10: 36 Aborted (core dumped) dotnet PermanentRedirectMinimal.dll
2022-06-03T03:43:42.474Z INFO - Waiting for response to warmup request for container annuaire_0_4715a3e4. Elapsed time = 19.6895811 sec
2022-06-03T03:43:42.508Z ERROR - Container blah_0_4715a3e4 for site blah has exited, failing site start
2022-06-03T03:43:42.511Z ERROR - Container blah_0_4715a3e4 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2022-06-03T03:43:42.520Z INFO - Stopping site blah because it failed during startup.
As confirmed by Azure Support, this scenario is not supported for Linux App Service. :( Azure power.
I'm trying to containerize an app with ASP.Net core & Angular.
It works perfectly - except for one thing. If I edit the Angular code, the pages do not update. After some research, I found out that I need to set the environment to development for my pages to get updated.
No problem - I can do that. I set it and then I get
asp.net | fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
asp.net | An unhandled exception has occurred while executing the request.
asp.net | System.AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this:.
asp.net |
asp.net | [1] Ensure that 'npm' is installed and can be found in one of the PATH directories.
asp.net | Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
asp.net | Make sure the executable is in one of those directories, or update your PATH.
asp.net |
asp.net | [2] See the InnerException for further details of the cause.))
asp.net | ---> System.AggregateException: One or more errors occurred. (Failed to start 'npm'. To resolve this:.
asp.net |
asp.net | [1] Ensure that 'npm' is installed and can be found in one of the PATH directories.
asp.net | Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
asp.net | Make sure the executable is in one of those directories, or update your PATH.
asp.net |
asp.net | [2] See the InnerException for further details of the cause.)
asp.net | ---> System.InvalidOperationException: Failed to start 'npm'. To resolve this:.
asp.net |
asp.net | [1] Ensure that 'npm' is installed and can be found in one of the PATH directories.
asp.net | Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
asp.net | Make sure the executable is in one of those directories, or update your PATH.
asp.net |
asp.net | [2] See the InnerException for further details of the cause.
asp.net | ---> System.ComponentModel.Win32Exception (2): No such file or directory
asp.net | at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
asp.net | at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
asp.net | at System.Diagnostics.Process.Start()
asp.net | at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
asp.net | at Microsoft.AspNetCore.NodeServices.Npm.NodeScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo, String commandName)
asp.net | --- End of inner exception stack trace ---
asp.net | at Microsoft.AspNetCore.NodeServices.Npm.NodeScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo, String commandName)
asp.net | at Microsoft.AspNetCore.NodeServices.Npm.NodeScriptRunner..ctor(String workingDirectory, String scriptName, String arguments, IDictionary`2 envVars, String pkgManagerCommand, DiagnosticSource diagnosticSource, CancellationToken applicationStoppingToken)
asp.net | at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(String sourcePath, String scriptName, String pkgManagerCommand, Int32 portNumber, ILogger logger, DiagnosticSource diagnosticSource, CancellationToken applicationStoppingToken)
asp.net | --- End of inner exception stack trace ---
asp.net | at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
asp.net | at System.Threading.Tasks.Task`1.get_Result()
asp.net | at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<>c.<Attach>b__2_0(Task`1 task)
asp.net | at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
asp.net | at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
asp.net | at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
asp.net | --- End of stack trace from previous location ---
asp.net | at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
asp.net | at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
asp.net | --- End of inner exception stack trace ---
asp.net | at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
asp.net | at System.Threading.Tasks.Task`1.get_Result()
asp.net | at Microsoft.AspNetCore.SpaServices.Extensions.Util.TaskTimeoutExtensions.WithTimeout[T](Task`1 task, TimeSpan timeoutDelay, String message)
asp.net | at Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task`1 baseUriTask, CancellationToken applicationStoppingToken, Boolean proxy404s)
asp.net | at Microsoft.AspNetCore.Builder.SpaProxyingExtensions.<>c__DisplayClass2_0.<<UseProxyToSpaDevelopmentServer>b__0>d.MoveNext()
asp.net | --- End of stack trace from previous location ---
asp.net | at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
for some reason. I don't know how to fix it.
My dockerfile:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 5000
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get update
RUN apt-get install -y nodejs
#EXPOSE 5001
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["mediere.csproj", "."]
RUN dotnet restore "./mediere.csproj"
COPY . .
WORKDIR "/src/."
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN dotnet build "mediere.csproj" -c Release -o /app/build
FROM build AS publish
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN npm install zone.js#0.11.3 --save
RUN dotnet publish "mediere.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "mediere.dll", "--environment=Development"]
my docker-compose.yml
version: "3.9"
services:
web:
container_name: asp.net
build:
context: .
dockerfile: Dockerfile
ports:
- "5000:5000"
environment:
ASPNETCORE_URLS: "http://+:5000"
depends_on:
- db
db:
container_name: postgres
image: postgres:latest
ports:
- "5432"
restart: always
volumes:
- db_volume:/var/lib/postgresql/data
environment:
POSTGRES_USER: ""
POSTGRES_PASSWORD: ""
POSTGRES_DB: ""
volumes:
db_volume:
as I said - as long as I don't set the environemnt to Development, everything works just fine. (but the pages do not update on editing the files)
So... how can I fix this error?
Thanks.
I have a dotnet application, which is not working as non-root user even though I am exposing it on port 5000, greater then the 1024 requirement.
WORKDIR /app
EXPOSE 5000
COPY app $local_artifact_path
RUN chown www-data:www-data /app /app/*
RUN chmod 777 /app
USER www-data
ENTRYPOINT dotnet $app_entry_point
The stacktrace is
warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
Using an in-memory repository. Keys will not be persisted to storage.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59]
Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {551dd8d6-67f6-4c6a-b5a4-9ea86b69593b} may be persisted to storage in unencrypted form.
crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.Net.Sockets.SocketException (13): Permission denied
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.AnyIPListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`
2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
Unhandled exception. System.Net.Sockets.SocketException (13): Permission denied
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.AnyIPListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at SanUserManagementService.Program.Main(String[] args) in /home/jankins/workspace/Daniel/dotnet/SanUserManagementService/Program.cs:line 10
Aborted (core dumped)
Any help related to this will be appreciated!
Thanks!
In my case the ASPNETCORE_URLS setting in environment variables or appsettings.json was set to http://+:80.
Changing it to http://+:5000 worked. Make sure you change your Docker port bindings as well, or load balancer settings if using AWS.
It works for me if the port is higher then 80. You need to run Kestrel on a different port within the code itself, maybe check the json files.
There might be running previous instance of your app in the server. Try running netstat -tulpn | grep LISTEN to see which PID is using the port(s) and kill it if necessary
I recently deleted one of the Wi-Fi that was remembered on my computer. Suddenly all projects failed to run.
Here's the console output
$ dotnet run
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/Users/user/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
Unhandled Exception: System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at testing.Program.Main(String[] args) in
I was using Visual Studio 2019 for Mac. .NET Core SDK and runtime versions:
dotnet --version
2.2.401
dotnet --list-sdks
2.2.401 [/usr/local/share/dotnet/sdk]
dotnet --list-runtimes
Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
I looked at some stackoverflow answers and they suggest it might be certificate problem. I have tried using the dotnet dev-certs tool to solve but it doesn't work. Plus I encountered something strange:
dotnet dev-certs https --check --verbose
No valid certificate found.
dotnet dev-certs https
A valid HTTPS certificate is already present.
dotnet dev-certs https --trust
Trusting the HTTPS development certificate was requested. If the certificate is not already trusted we will run the following command:
'sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain <<certificate>>'
This command might prompt you for your password to install the certificate on the system keychain.
A valid HTTPS certificate is already present.
The dev-certs checking option produce contradicting results with command that create the new search
The dotnet-dev-certs version is 2.2.0
In my keychain, there is no certificate for localhost. Then I tried re-installing the dotNET SDKs and Visual Studio but also doesn't work.
I'm going through same problem and finally, I relief from this doing 2 things in command prompt.
dotnet dev-certs https --clean
dotnet dev-certs https --trust
C:\Users\saifs>dotnet dev-certs https --clean
Cleaning HTTPS development certificates from the machine. A prompt might get displayed to confirm the removal of some of the certificates.
C:\Users\saifs>dotnet dev-certs https
The HTTPS developer certificate was generated successfully.
C:\Users\saifs>dotnet dev-certs https --trust
Trusting the HTTPS development certificate was requested. A confirmation prompt will be displayed if the certificate was not previously trusted. Click yes on the prompt to trust the certificate.
A valid HTTPS certificate is already present.