I'm trying to deploy an ASP.NET Core Web API on render.com, but it isn't working. The logs say it's something in the connection string, but I'm literally copying and pasting, there's nothing wrong with it.
I also deployed the database using render (Postgres) in the free version, as well as deploying the API in C#.
API on GitHub: https://github.com/LucasAPessoa/DevBrecho
I tried to generate the database and the web service again, add the block below in Program.cs to force migrations, but it still didn't work.
It's a simple API and doesn't have any authentication, nothing too complex
using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<SeuDbContext>();
dbContext.Database.Migrate();
}
PS: The deploy works, but every time I make a request (any) on insomnia, a error appear on logs (see below)
How can I fix this? what is causing the error? maybe a misconfiguration on render.com? Or a misconfiguration in Program.cs?
2025-10-14T22:30:12.089010337Z at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
2025-10-14T22:30:12.089016777Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
2025-10-14T22:30:12.089020998Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-10-14T22:30:12.089023438Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
2025-10-14T22:30:12.089025658Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2025-10-14T22:30:12.089028488Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
2025-10-14T22:30:12.089030978Z --- End of stack trace from previous location ---
2025-10-14T22:30:12.089033228Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-10-14T22:30:12.089047318Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-10-14T22:30:12.089049958Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-10-14T22:30:12.089052318Z at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
2025-10-14T22:30:12.089054538Z at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2025-10-14T22:30:12.089056689Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
2025-10-14T22:35:04.74167339Z ==> Detected service running on port 8080
2025-10-14T22:35:05.02634937Z ==> Docs on specifying a port: https://render.com/docs/web-services#port-binding
2025-10-14T22:45:15.937154421Z info: Microsoft.Hosting.Lifetime[0]
2025-10-14T22:45:15.937175902Z Application is shutting down...
2025-10-15T01:09:09.171057962Z ==> Deploying...
2025-10-15T01:09:17.161668653Z info: Microsoft.Hosting.Lifetime[0]
2025-10-15T01:09:17.161671273Z Hosting environment: Production
2025-10-15T01:09:17.161673194Z info: Microsoft.Hosting.Lifetime[0]
2025-10-15T01:09:17.161675584Z Content root path: /app
2025-10-15T01:09:19.760952775Z warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
2025-10-15T01:09:19.760977157Z Failed to determine the https port for redirect.
2025-10-15T01:09:21.427105884Z ==> Your service is live 🎉
2025-10-15T01:09:21.50083954Z ==>
2025-10-15T01:09:22.548193828Z ==> ///////////////////////////////////////////////////////////
2025-10-15T01:09:23.662334813Z ==>
2025-10-15T01:09:23.745357108Z ==> Available at your primary URL https://devbrecho.onrender.com
2025-10-15T01:09:23.827619213Z ==>
2025-10-15T01:09:24.974357276Z ==> ///////////////////////////////////////////////////////////
2025-10-15T01:10:16.864438819Z fail: Microsoft.EntityFrameworkCore.Query[10100]
2025-10-15T01:10:16.864467121Z An exception occurred while iterating over the results of a query for context type 'DevBrecho.Data.AppDbContext'.
2025-10-15T01:10:16.864476442Z System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
2025-10-15T01:10:16.864481842Z at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)
2025-10-15T01:10:16.864486312Z at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
2025-10-15T01:10:16.864489042Z at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms, Boolean useOdbcRules)
2025-10-15T01:10:16.864492292Z at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
2025-10-15T01:10:16.864495383Z at Npgsql.NpgsqlConnectionStringBuilder..ctor(String connectionString)
2025-10-15T01:10:16.864498793Z at Npgsql.NpgsqlConnection.SetupDataSource()
2025-10-15T01:10:16.864501453Z at Npgsql.NpgsqlConnection.set_ConnectionString(String value)
2025-10-15T01:10:16.864504073Z at Npgsql.NpgsqlConnection..ctor(String connectionString)
2025-10-15T01:10:16.864506653Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlRelationalConnection.CreateDbConnection()
2025-10-15T01:10:16.864509204Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()
2025-10-15T01:10:16.864512324Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
2025-10-15T01:10:16.864514944Z at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
2025-10-15T01:10:16.864553086Z at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
2025-10-15T01:10:16.864561047Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
2025-10-15T01:10:16.864564887Z at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
2025-10-15T01:10:16.864568797Z System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
2025-10-15T01:10:16.864573007Z at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)
2025-10-15T01:10:16.864587668Z at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
2025-10-15T01:10:16.864589378Z at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms, Boolean useOdbcRules)
2025-10-15T01:10:16.864591069Z at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
2025-10-15T01:10:16.864592638Z at Npgsql.NpgsqlConnectionStringBuilder..ctor(String connectionString)
2025-10-15T01:10:16.864594189Z at Npgsql.NpgsqlConnection.SetupDataSource()
2025-10-15T01:10:16.864595769Z at Npgsql.NpgsqlConnection.set_ConnectionString(String value)
2025-10-15T01:10:16.864597279Z at Npgsql.NpgsqlConnection..ctor(String connectionString)
2025-10-15T01:10:16.864598919Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlRelationalConnection.CreateDbConnection()
2025-10-15T01:10:16.864600399Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()
2025-10-15T01:10:16.864602019Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
2025-10-15T01:10:16.864603619Z at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
2025-10-15T01:10:16.864605269Z at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
2025-10-15T01:10:16.864606779Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
2025-10-15T01:10:16.86462125Z at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
2025-10-15T01:10:16.959699068Z fail: Microsoft.AspNetCore.Server.Kestrel[13]
2025-10-15T01:10:16.959720529Z Connection id "0HNGBGTRVAR7Q", Request id "0HNGBGTRVAR7Q:00000002": An unhandled exception was thrown by the application.
2025-10-15T01:10:16.959723459Z System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
2025-10-15T01:10:16.959726089Z at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)
2025-10-15T01:10:16.95972865Z at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
2025-10-15T01:10:16.9597309Z at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms, Boolean useOdbcRules)
2025-10-15T01:10:16.95973356Z at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
2025-10-15T01:10:16.95973613Z at Npgsql.NpgsqlConnectionStringBuilder..ctor(String connectionString)
2025-10-15T01:10:16.95973897Z at Npgsql.NpgsqlConnection.SetupDataSource()
2025-10-15T01:10:16.959741201Z at Npgsql.NpgsqlConnection.set_ConnectionString(String value)
2025-10-15T01:10:16.95974327Z at Npgsql.NpgsqlConnection..ctor(String connectionString)
2025-10-15T01:10:16.959745251Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlRelationalConnection.CreateDbConnection()
2025-10-15T01:10:16.959747201Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()
2025-10-15T01:10:16.959759922Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
2025-10-15T01:10:16.959762362Z at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
2025-10-15T01:10:16.959764762Z at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
2025-10-15T01:10:16.959767392Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
2025-10-15T01:10:16.959769312Z at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
2025-10-15T01:10:16.959771712Z at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
2025-10-15T01:10:16.959773532Z at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
2025-10-15T01:10:16.959775352Z at DevBrecho.Controllers.SetorController.GetSetores() in /source/DevBrecho/Controllers/SetorController.cs:line 23
2025-10-15T01:10:16.959777273Z at lambda_method4(Closure, Object)
2025-10-15T01:10:16.959779583Z at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
2025-10-15T01:10:16.959785073Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
2025-10-15T01:10:16.959787573Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-10-15T01:10:16.959789383Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
2025-10-15T01:10:16.959791193Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2025-10-15T01:10:16.959793733Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
2025-10-15T01:10:16.959795584Z --- End of stack trace from previous location ---
2025-10-15T01:10:16.959797454Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-10-15T01:10:16.959813275Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-10-15T01:10:16.959815775Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-10-15T01:10:16.959817655Z at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
2025-10-15T01:10:16.959819435Z at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2025-10-15T01:10:16.959821415Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
2025-10-15T01:18:37.923913346Z ==> Detected service running on port 8080
2025-10-15T01:18:38.226328702Z ==> Docs on specifying a port: https://render.com/docs/web-services#port-binding
Here are some render configs


