I have hosted a MySQL DB on AWS EC2 instance(t2.micro, ubuntu, free tier). I am able to connect to it and store data. But most of the time, I am unable to connect to it via workbench or my app. But my configurations are correct since I am able to connect to it sometime and store values.
The workbench throws the following error:
Lost connection to MySQL server at 'reading initial communication packet', system error: 104
.
The app throws an ETIMEDOUT
error.
What's wrong here? I have checked Cloudwatch metrics also, but there is no warning on CPU out of credits also. This issue persists continuously for days now(between I am able to connect to the DB randomly). and no useful info about it anywhere.
[edit]: I am trying to connect via my local machine. And the app is also not hosted in EC2, it is on another server.
SELECT @@version;
results:
8.0.30-0ubuntu0.22.04.1
SHOW GLOBAL STATUS LIKE 'aborted%';
results:
Aborted_clients | 516 | | Aborted_connects | 357
SHOW GLOBAL STATUS LIKE '%connect%';
results:
Aborted_connects | 357 | | Connection_errors_accept | 0 | | Connection_errors_internal | 0 | | Connection_errors_max_connections | 0 | | Connection_errors_peer_address | 0 | | Connection_errors_select | 0 | | Connection_errors_tcpwrap | 0 | | Connections | 895 | | Global_connection_memory | 0 | | Locked_connects | 0 | | Max_used_connections | 13 | | Max_used_connections_time | 2022-09-08 10:19:10 | | Mysqlx_connection_accept_errors | 0 | | Mysqlx_connection_errors | 0 | | Mysqlx_connections_accepted | 0 | | Mysqlx_connections_closed | 0 | | Mysqlx_connections_rejected | 0 | | Performance_schema_session_connect_attrs_longest_seen | 117 | | Performance_schema_session_connect_attrs_lost | 0 | | Ssl_client_connects | 0 | | Ssl_connect_renegotiates | 0 | | Ssl_finished_connects | 0 | | Threads_connected | 2
SHOW GLOBAL VARIABLES LIKE '%timeo%';
results:
| connect_timeout | 10 | | delayed_insert_timeout | 300 | | have_statement_timeout | YES | | innodb_flush_log_at_timeout | 1 | | innodb_lock_wait_timeout | 50 | | innodb_rollback_on_timeout | OFF | | interactive_timeout | 28800 | | lock_wait_timeout | 31536000 | | mysqlx_connect_timeout | 30 | | mysqlx_idle_worker_thread_timeout | 60 | | mysqlx_interactive_timeout | 28800 | | mysqlx_port_open_timeout | 0 | | mysqlx_read_timeout | 30 | | mysqlx_wait_timeout | 28800 | | mysqlx_write_timeout | 60 | | net_read_timeout | 30 | | net_write_timeout | 60 | | replica_net_timeout | 60 | | rpl_stop_replica_timeout | 31536000 | | rpl_stop_slave_timeout | 31536000 | | slave_net_timeout | 60 | | ssl_session_cache_timeout | 300 | | wait_timeout | 28800
SHOW GLOBAL VARIABLES LIKE 'max_allowed%';
results:
max_allowed_packet | 67108864