System.ArgumentException: ‘The path must be absolute’

Getting this error because you are trying to Host Blazor Server on Docker

Choosing Production environment over Development Environment and specifying the certificate path used by Kestrel , will not give you ‘The path must be absolute’ and everything will work fine.

Why talking about Kestrel?

Switching to Production environment, Kestrel needs a true generated certificate. Which means not the certificate generated for localhost.

Running Blazor server on Docker

Running Blazor server on Docker, will give you a system argument exception telling you that “The path must be absolute’. Specifically running Blazor server using docker-compose will give you the error ‘The path must be absolute’.

But, running Blazor server by just execution the docker file you could not have this problem.

Docker-compose vs Docker file

Running Blazor server on Docker using docker-compose it is the preferred method. Because, you will be hosting Blazor Server, Nginx and database server.

With docker-compose you could deploy many application and service executing one simple command. which is “docker-compose up“.

docker-compose.override.yml file

When using docker. the environment variable, define if the application is in development or production.

Open docker-compose.override.yml file and set the environment variable.

version: '3.4'


      - ASPNETCORE_URLS=https://+:443;http://+:80
      - "80"
      - "443"
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
  • 2. Compile and Run the Application

After running the application a new error will appear because Kestrel wants to know the location of the certificate.

Open appsettings.json and add the path to your certificate. Use the same path.

But, what about the certificate name and the password.

 "Kestrel": {
    "Certificates": {
      "Default": {
        "Path": "/root/.aspnet/https/BlazorApp.pfx",
        "Password": "6e40e96e-c7fd-4507-bdac-28094f982aa7"

The certificate could be found at :


and for the password : you will find it in Manage User Secrets

Finally for testing: copy and paste the code below in your Index.razor file

@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnv

<p> ASPNETCORE_ENVIRONMENT = @hostingEnv.EnvironmentName</p>

Set the output to Release

and run the application. you will get the result telling, which environment the application use.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *