0

I am trying to make a remote connection from my web API in net core 3.1 and when performing scaffold it returns the following message where it cannot connect.

I already tried several alternatives until opening the ports of my RDS without success, what can I be missing?

Build started...
Build succeeded.
MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
   at MySqlConnector.Core.ServerSession.ConnectAsync(ConnectionSettings cs, ILoadBalancer loadBalancer, IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ServerSession.cs:line 442
   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ConnectionPool.cs:line 112
   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ConnectionPool.cs:line 141
   at MySql.Data.MySqlClient.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Nullable`1 ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 645
   at MySql.Data.MySqlClient.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 312
   at MySql.Data.MySqlClient.MySqlConnection.Open() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 280
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Unable to connect to any of the specified MySQL hosts.
  • Unable to connect means that mysql is not running, or listens on a different port, or does not listen on any ports, or your network configuration prevents the client from connecting to mysql. It is up to you to figure out which one of these causes the actual error. – Shadow Sep 30 '21 at 08:47
  • I have placed the same configuration that you use to enter the workbrech or are they totally different types of connections? – Robinson Ascencio Peña Sep 30 '21 at 14:16
  • If your workbench runs on the same computer as your code, then the same connection details should be fine. Otherwise nhere may be networking differences. – Shadow Sep 30 '21 at 14:34
  • in this case my database is in an amazon RDS service where in workbrench if I can connect but when performing the scaffold it cannot connect to the host – Robinson Ascencio Peña Sep 30 '21 at 14:39
  • Does your code run on the same machine as your workbencs? Yes or no? – Shadow Sep 30 '21 at 14:42
  • If web api is on my local pc, my database is on amazon rds – Robinson Ascencio Peña Sep 30 '21 at 14:48
  • And where is your workbench running??? This is a 3rd time I'm asking this.... – Shadow Sep 30 '21 at 14:49
  • Workbrech is on my local pc – Robinson Ascencio Peña Sep 30 '21 at 15:02
  • Then the same connection details should work, but local firewall or anti virus software may interfere with it. – Shadow Sep 30 '21 at 15:04
  • I added an Answer to this related Question. It might be helpful to some. It's about setting Inbound/Outbound rules to the VPC Security group associated to the RDS MySQL database. https://stackoverflow.com/questions/59386577/unable-to-connect-to-any-of-the-specific-mysql-hosts-with-aws-lambda-to-rds-mysq – StackOverflowUser Aug 16 '22 at 08:23

0 Answers0