0

One Mysql master db server and 5 remote web servers connecting to the master server. web servers are ubuntu servers with custom PHP code and redis cache used. Websites randomly showing below error. All servers are running on aws.

Can't connect to MySQL server mysql-server-ip (99)

Also apache logs showing same error PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'server-ip' (99)'

I have tried increasing max_connections variable on my.cnf file

SHOW GLOBAL STATUS LIKE 'Max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 738   |
+----------------------+-------+

SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 12000 |
+-----------------+-------+

my.cnf file

skip_external_locking           = 1  
thread_cache_size               = 24  
table_open_cache                = 2048  
table_definition_cache          = 512  

back_log                        = 128
max_connections                 = 12000
max_connect_errors              = 10000
open-files-limit                = 20000
interactive_timeout             = 60
wait_timeout                    = 1200
net_read_timeout                = 300
net_write_timeout               = 300  

netstat -nat | grep 3306|grep TIME_WAIT |wc -l
93
netstat -anp | grep :3306 | grep ESTABLISHED | wc -l
13
cat /proc/sys/net/ipv4/ip_local_port_range
32768 61000
Most of the TIME_WAIT connections on db server is from a webserver

  • Errno 99 is Cannot assign requested address. You need to look at the instances' networking configuration. – Michael Hampton Jan 27 '17 at 19:52
  • @MichaelHampton netstat -nat | grep 3306|grep TIME_WAIT |wc -l >> 93 netstat -anp | grep :3306 | grep ESTABLISHED | wc -l >> 13 also port range 32768-61000 how can i resolve this – adminz Jan 27 '17 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.