Change Yarp Port number from 5000 when deploying

124 views Asked by At

I have deployed YARP onto my live server (via Visual Studio publish), however I cannot seem to change the port, it only listens on http://localhost:5000

On my dev PC I have launchsettings.json file this does not get published (not sure if this is used when deployed), I copied launchsettings.json onto my live server into the root folder of the YARP deployment and also tried in a folder called 'Properties' (like it is my dev PC) but it does not seem to use this file:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:28010",
      "sslPort": 44361
    }
  },
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "http://localhost:5237",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:7168;http://localhost:5237",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

I also tried adding the URLS entry into appsettings.json entry as per this segment:

{
  "Urls": "http://localhost:5237",
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },

Any ideas?

It should listen on ports http 5237 and https 7168 as per my launchsettings.

1

There are 1 answers

0
David On

For anyone struggling with this, it gives you a hint when you start Yarp it says "Content root path: C:\Users\Administrator" (or whatever user you are running it under). You need to copy the appsettings.json file into this folder rather than the folder where your Yarp exe and dlls are located.