I'm trying to Deploy .Net 6 app with multiple projects to Linux Elastic Beanstalk Server from mac development machine. I'm having trouble querying the api after it has been deployed. I've done it in 2 ways - Just an EC2 instance by following this tutorial, just using command line, and through Elastic beanstalk console. So I have 2 EC2 instances. They both say they are running.
The project has one Asp.Net app (Vepo.Web) and 5 helper projects for the app layers. the "Vepo" project is just a placeholder I made because the internet told me there is a bug when you name your dll different to your solution; and the solution is "Vepo.sln".
The files created by the publish look like this:
I got the source code to deploy by cd into my asp.net core web app (Vepo.Web), then run dotnet publish -r linux-x64 --self-contained false --output build
, then go to "Vepo.Web/build" in finder. Then select all files > right-click > compress (do not compress the parent folder!). That creates "archive.zip". Then upload "archive.zip" in the Elastic Beanstalk Console. And now it looks like this:
But I don't seem to be able to query the api. In Postman I'm trying:
ec2-54-xxx-xxx-95.ap-southeast-2.compute.amazonaws.com:5001/Users
but I get:
Error: connect ECONNREFUSED 54.xxx.xxx.95:5000
And navigating to it gives me:
I have created these inbound rules to allow anyone in because I'm desperately trying to get in:
Can someone help me be able to hit endpoints in my web API without getting 404/401? I will give any information required if I'm missing something.
UPDATE: I guess the app is running when I ssh into it and run this command (no idea how to access it from postman or my app, going to this in the browser does not work https://ec2-54-xxx-xxx-53.ap-southeast-2.compute.amazonaws.com:5001/fashionitems/search?searchTerm=B¤tPage=1&pageSize=10):
ubuntu@ip-172-31-44-141:~/app$ ./Vepo.Web —urls http://+:5000 —environment Development
warn: Microsoft.EntityFrameworkCore.Model.Validation[10400]
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
warn: 02/27/2022 03:25:03.441 CoreEventId.SensitiveDataLoggingEnabledWarning[10400] (Microsoft.EntityFrameworkCore.Infrastructure)
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'VeganItem.Tags' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: 02/27/2022 03:25:03.455 CoreEventId.CollectionWithoutComparer[10620] (Microsoft.EntityFrameworkCore.Model.Validation)
The property 'VeganItem.Tags' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
info: 02/27/2022 03:25:03.716 CoreEventId.ContextInitialized[10403] (Microsoft.EntityFrameworkCore.Infrastructure)
Entity Framework Core 6.0.0 initialized 'VepoContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL:6.0.0+025fc55189ae41e3f2b98bcbe4eb44c505653700' with options: SensitiveDataLoggingEnabled DetailedErrorsEnabled using NetTopologySuite
dbug: 02/27/2022 03:25:05.976 CoreEventId.QueryCompilationStarting[10111] (Microsoft.EntityFrameworkCore.Query)
Compiling query expression:
'DbSet<VeganItem>()'
dbug: 02/27/2022 03:25:06.200 CoreEventId.QueryExecutionPlanned[10107] (Microsoft.EntityFrameworkCore.Query)
Generated query execution expression:
'queryContext => new SingleQueryingEnumerable<VeganItem>(
(RelationalQueryContext)queryContext,
RelationalCommandCache.SelectExpression(
Projection Mapping:
EmptyProjectionMember -> Dictionary<IProperty, int> { [Property: VeganItem.Id (int) Required PK AfterSave:Throw ValueGenerated.OnAdd, 0], [Property: VeganItem.CompanyName (string) Required Index MaxLength(256), 1], [Property: VeganItem.CreatedById (string) FK Index MaxLength(256), 2], [Property: VeganItem.CreatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 3], [Property: VeganItem.Description (string) MaxLength(256), 4], [Property: VeganItem.Discriminator (string) Required Index AfterSave:Throw MaxLength(256), 5], [Property: VeganItem.Images (List<string>) MaxLength(10), 6], [Property: VeganItem.IsNotVeganCount (int) Required, 7], [Property: VeganItem.IsVeganCount (int) Required, 8], [Property: VeganItem.Name (string) Required Index MaxLength(256), 9], [Property: VeganItem.Rating (int) Required, 10], [Property: VeganItem.RatingsCount (int) Required, 11], [Property: VeganItem.Tags (List<Option>), 12], [Property: VeganItem.UpdatedById (string) FK Index MaxLength(256), 13], [Property: VeganItem.UpdatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 14], [Property: EventItem.LocationName (string) Required Index MaxLength(256), 15], [Property: FashionItem.Age (Option) Required, 16], [Property: FashionItem.Gender (Option) Required, 17], [Property: RecipeItem.CookTime (TimeSpan) Required, 18], [Property: RecipeItem.Difficulty (Option) Required, 19], [Property: RecipeItem.Ingredients (List<string>) Required MaxLength(100), 20], [Property: RecipeItem.Method (List<string>) Required MaxLength(100), 21], [Property: RecipeItem.PrepTime (TimeSpan) Required, 22], [Property: RecipeItem.ServesCount (int) Required, 23], [Property: RecipeItem.Tips (List<string>) MaxLength(2), 24] }
SELECT v.Id, v.CompanyName, v.CreatedById, v.CreatedDate, v.Description, v.Discriminator, v.Images, v.IsNotVeganCount, v.IsVeganCount, v.Name, v.Rating, v.RatingsCount, v.Tags, v.UpdatedById, v.UpdatedDate, v.LocationName, v.Age, v.Gender, v.CookTime, v.Difficulty, v.Ingredients, v.Method, v.PrepTime, v.ServesCount, v.Tips
FROM VeganItems AS v),
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, VeganItem>,
Vepo.DataContext.VepoContext,
False,
True,
True
)'
dbug: 02/27/2022 03:25:06.262 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:06.267 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (34ms).
dbug: 02/27/2022 03:25:06.270 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.464 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.469 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
info: 02/27/2022 03:25:06.546 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (77ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
dbug: 02/27/2022 03:25:06.629 CoreEventId.StartedTracking[10806] (Microsoft.EntityFrameworkCore.ChangeTracking)
Context 'VepoContext' started tracking 'MenuItem' entity with key '{Id: 1}'.
dbug: 02/27/2022 03:25:06.687 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:06.689 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.693 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:06.694 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:06.694 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.695 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
info: 02/27/2022 03:25:06.697 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CompanyName", v."CreatedById", v."CreatedDate", v."Description", v."Discriminator", v."Images", v."IsNotVeganCount", v."IsVeganCount", v."Name", v."Rating", v."RatingsCount", v."Tags", v."UpdatedById", v."UpdatedDate", v."LocationName", v."Age", v."Gender", v."CookTime", v."Difficulty", v."Ingredients", v."Method", v."PrepTime", v."ServesCount", v."Tips"
FROM "VeganItems" AS v
dbug: 02/27/2022 03:25:06.698 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:06.698 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:06.698 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.201 CoreEventId.QueryCompilationStarting[10111] (Microsoft.EntityFrameworkCore.Query)
Compiling query expression:
'DbSet<VeganItemEstablishment>()'
dbug: 02/27/2022 03:25:07.232 CoreEventId.QueryExecutionPlanned[10107] (Microsoft.EntityFrameworkCore.Query)
Generated query execution expression:
'queryContext => new SingleQueryingEnumerable<VeganItemEstablishment>(
(RelationalQueryContext)queryContext,
RelationalCommandCache.SelectExpression(
Projection Mapping:
EmptyProjectionMember -> Dictionary<IProperty, int> { [Property: VeganItemEstablishment.Id (int) Required PK AfterSave:Throw ValueGenerated.OnAdd, 0], [Property: VeganItemEstablishment.CreatedById (string) FK Index MaxLength(256), 1], [Property: VeganItemEstablishment.CreatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 2], [Property: VeganItemEstablishment.Discriminator (string) Required AfterSave:Throw MaxLength(256), 3], [Property: VeganItemEstablishment.EstablishmentId (int?) FK Index, 4], [Property: VeganItemEstablishment.InEstablishmentCount (int) Required, 5], [Property: VeganItemEstablishment.NotInEstablishmentCount (int) Required, 6], [Property: VeganItemEstablishment.Price (double) Required, 7], [Property: VeganItemEstablishment.UpdatedById (string) FK Index MaxLength(256), 8], [Property: VeganItemEstablishment.UpdatedDate (DateTime) Required BeforeSave:Ignore AfterSave:Ignore ValueGenerated.OnAddOrUpdate, 9], [Property: VeganItemEstablishment.VeganItemId (int) Required FK Index, 10], [Property: EventItemEstablishment.Dates (List<NpgsqlRange<DateTime>>) Required MaxLength(10), 11] }
SELECT v.Id, v.CreatedById, v.CreatedDate, v.Discriminator, v.EstablishmentId, v.InEstablishmentCount, v.NotInEstablishmentCount, v.Price, v.UpdatedById, v.UpdatedDate, v.VeganItemId, v.Dates
FROM VeganItemEstablishments AS v),
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, VeganItemEstablishment>,
Vepo.DataContext.VepoContext,
False,
True,
True
)'
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:07.233 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.233 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
info: 02/27/2022 03:25:07.238 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
dbug: 02/27/2022 03:25:07.243 CoreEventId.StartedTracking[10806] (Microsoft.EntityFrameworkCore.ChangeTracking)
Context 'VepoContext' started tracking 'MenuItemEstablishment' entity with key '{Id: 1}'.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.290 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandCreating[20103] (Microsoft.EntityFrameworkCore.Database.Command)
Creating DbCommand for 'ExecuteReader'.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandCreated[20104] (Microsoft.EntityFrameworkCore.Database.Command)
Created DbCommand for 'ExecuteReader' (0ms).
dbug: 02/27/2022 03:25:07.291 RelationalEventId.ConnectionOpening[20000] (Microsoft.EntityFrameworkCore.Database.Connection)
Opening connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.ConnectionOpened[20001] (Microsoft.EntityFrameworkCore.Database.Connection)
Opened connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.291 RelationalEventId.CommandExecuting[20100] (Microsoft.EntityFrameworkCore.Database.Command)
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
info: 02/27/2022 03:25:07.293 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
FROM "VeganItemEstablishments" AS v
dbug: 02/27/2022 03:25:07.293 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
A data reader was disposed.
dbug: 02/27/2022 03:25:07.294 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
dbug: 02/27/2022 03:25:07.294 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Closed connection to database 'vepo_admin' on server ''.
dbug: 02/27/2022 03:25:07.407 CoreEventId.ContextDisposed[10407] (Microsoft.EntityFrameworkCore.Infrastructure)
'VepoContext' disposed.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/ubuntu/app
P.S. I much prefer the console, I am a gui guy, and would way rather solve this with the AWS console.
Is this browser message any better? Sounds kinda like it exists but I need to provide auth/key:
I redeployed on elastic beanstalk and got these logs:
Mar 1 05:55:49 ip-172-31-2-81 web: Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
Mar 1 05:55:49 ip-172-31-2-81 web: SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
Mar 1 05:55:49 ip-172-31-2-81 web: FROM "VeganItemEstablishments" AS v
Mar 1 05:55:49 ip-172-31-2-81 web: info: 3/1/2022 05:55:49.622 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Mar 1 05:55:49 ip-172-31-2-81 web: Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
Mar 1 05:55:49 ip-172-31-2-81 web: SELECT v."Id", v."CreatedById", v."CreatedDate", v."Discriminator", v."EstablishmentId", v."InEstablishmentCount", v."NotInEstablishmentCount", v."Price", v."UpdatedById", v."UpdatedDate", v."VeganItemId", v."Dates"
Mar 1 05:55:49 ip-172-31-2-81 web: FROM "VeganItemEstablishments" AS v
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.DataReaderDisposing[20300] (Microsoft.EntityFrameworkCore.Database.Command)
Mar 1 05:55:49 ip-172-31-2-81 web: A data reader was disposed.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.ConnectionClosing[20002] (Microsoft.EntityFrameworkCore.Database.Connection)
Mar 1 05:55:49 ip-172-31-2-81 web: Closing connection to database 'vepo_admin' on server 'tcp://vepo-qa-database.clzwnfnywws7.ap-southeast-2.rds.amazonaws.com:5432'.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.623 RelationalEventId.ConnectionClosed[20003] (Microsoft.EntityFrameworkCore.Database.Connection)
Mar 1 05:55:49 ip-172-31-2-81 web: Closed connection to database 'vepo_admin' on server ''.
Mar 1 05:55:49 ip-172-31-2-81 web: dbug: 3/1/2022 05:55:49.714 CoreEventId.ContextDisposed[10407] (Microsoft.EntityFrameworkCore.Infrastructure)
Mar 1 05:55:49 ip-172-31-2-81 web: 'VepoContext' disposed.
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[14]
Mar 1 05:55:49 ip-172-31-2-81 web: Now listening on: http://localhost:5000
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Application started. Press Ctrl+C to shut down.
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Hosting environment: Production
Mar 1 05:55:49 ip-172-31-2-81 web: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Mar 1 05:55:49 ip-172-31-2-81 web: Content root path: /var/app/current
I guess key things that seem wrong are "now listening on: http://localhost:5000" (shouldn't that be my ec2 instance public ipv4 address?) and "Hosting environment: Production" as I can only confirm development env working, so I will try to run locally in Production version now.
After adding as per accepted answer, it worked.:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("http://*:5000");
});
The answer basically try summarizing the different comments posted in the question.
The problem can be motivated for many different reasons.
The most important thing to keep in mind is that EB provides a nginx proxy for serving the application.
By default this proxy expects your application to listen on port 5000
.
According to the logs you provided, the application seems to start properly and it successfully connect to the database.
As you pointed out, it reports that the application is listening on http://localhost:5000
: it may not be a problem, but perhaps your application is listening only in a certain network interface/address.
Just to be sure, and in fact, at the end it seems to be the solution, configure your application Kestrel server to listen on the mask http://*:5000
, using .UseUrls("http://*:5000")
in your Startup
class, for instance. This article provides several different options for configuring where the application should listen to.