I keep getting this error from the heroku logs:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
I have an ASP.NET Core 2.1 app that I'm trying to deploy to Heroku. This is what I do at startup:
if (!int.TryParse(Environment.GetEnvironmentVariable("PORT"), out var port))
{ port = 5000; }
return WebHost
.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Listen(IPAddress.Loopback, port);
});
This is my Dockerfile
FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
COPY . .
ENV ASPNETCORE_ENVIRONMENT=Production
CMD dotnet MyApp.dll
I can see the app is starting OK, I even see it's successfully binding to something like http://127.0.0.1:48684
which means it's getting the $PORT
, but at the time of a request I get the above error. I cannot use EXPOSE $PORT
because it's given at run time.
I've been wrestling with this for a while now. Any help would be much appreciated.