Sudden "unknown MySQL server host error" on AWS with Django - mysql

I am receiving a lot of error reports from my Django server throwing:
(2005, "Unknown MySQL server host 'my-address.us-east-1.rds.amazonaws.com' (0)").
The server has been connecting to this database for more than a year without any issue. But this morning I suddenly started to receive this error, even though I didn't do any changes to the code.
Furthermore, when I connect to my website, it actually loads data from the database fine.
Apparently there is a random chance that it won't manage to connect?
Any idea what can cause that and how to fix it?
I am on Amazon lightsail.

There is an active AWS DNS resolving incident in us-east-1 region. Seems like it will be mitigated soon.
https://status.aws.amazon.com/
UPDATE: The issue is now resolved as updated by AWS.

Related

SQL Communications link failure when accessing SQL database on the same machine

I am running a Minecraft server which is querying a SQL database on the same VPS as the game server for various bits of data (ranks, warps and such). Today have encountered something which has stumped me and I am turning to you hoping for an answer.
My VPS is running Ubuntu Server 18.04.4 LTS, the Minecraft server is being ran from within a screen instance and no changes to the server, operating system or mySQL that I am aware of have been made that could have caused an issue and given I am the only one with SSH access to the server theres no way an update could have been made unless it was silently updated in the background without my knowledge. The problem just randomly happened out of nowhere.
The specific error I am getting (output from MC server console)
2021-05-19 12:44:51 [INFO] [STDOUT] [SERVERMANAGER EXCEPTION | com.mysql.cj.jdbc.exceptions.CommunicationsException] Communications link failure
2021-05-19 12:44:51 [INFO] [STDOUT] The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Granted I have little experience with SQL (I inherited this SQL setup from someone else who I am unable to contact for assistance to fix this) but the last message of this error lead me to believe that everything with the Minecraft server itself was fine and the SQL database simply was not acknowledging the packets the Minecraft server was sending.
However despite...
Restarting the mySQL service with sudo service mysql restart
Verifying that the servermanager database I am using is still present with SHOW DATABASES;
Verifying that the three tables servermanager has are still present with SHOW TABLES;
Restarting the VPS
I cannot for the life of me seem to get this issue to fix itself!
Anyone able to offer any insight?

How do I connect a to a mysql database hosted on pythonanywhere?

I have bought a basic 6$ pythonanywhere server which allows for SCP and SSH connections to their servers. I have deployed my flask application (REST API) to the server and set up a local environment (installed packages, set up path and environmental variables). I ran the app, and it gives me the 404 page on the / route which is actually a sign that it is working.
However when I try to hit a route like /api/users/3 for example, it gives me an error 500 (internal server error). I dug around some log files on the server and found one which is basically the output of the WSGI web server which is host to my flask application. It said that there is an issue with the database communication. From what I understand, it connected successfully but it couldn't query the data from the table:
(1044, "Access denied for user 'secret_username'#'%' to database 'test'")
I have tried to fix this through the web mysql console by giving my <secret_username>#secret_username.pythonanywhere.com all the privilages to test.*, but it gives me an access error once again. I tried to SSH into the machine that is host to the mysql server and tried to connect to it - secret_username.mysql.pythonanywhere-services.com but it doesn't allow me to ssh into this server.
Has anyone experienced this issue? I am almost sure that my connection is set up correctly because if it didn't establish connection it would give me an access error with message `using password "yes". I've read on forums a bit, they suggest installing a mysql server on the same server as the flask application, but I don't have access to sude for some reason, probably due to my cheap plan. Any ideas?
If you are using the MySQL database provided by PythonAnywhere, with the hostname secret_username.mysql.pythonanywhere-services.com, then your database will be called secret_username$test, not just test -- see the "Databases" page on the PythonAnywhere website.

Error 2003 (HY000): can't connect to MySQL server on ' IPv4 address' (10060)

I have a Google Cloud SQL Instance that I have been using for some time now and connecting successfully from MySQL Workbench. However as of yesterday I can't connect using MySQL Workbench (or the command line on my laptop) and get the error:
ERROR 2003 (HY000): Can't connect to MySQL server on '207.xxx.xxx.xx' (10060)
I have done the following already:
Authorised my laptop's IP address (found using whatismyip.com) in the Google Console.
Assigned an IPv4 address to the database in the Google Console.
Created new users and passwords to see if it was a user issue. But that didn't help.
Restarted the instance, restarted my home network/laptop and got new IP addresses (and updated the authorised IP address accordingly).
Upgraded to the latest MySQL workbench 6.3 CE but still have the issue.
The database works as my app can connect to it and accesses the data, I just can't get a remote connection from my laptop.
I am new to this and am out of ideas on how to fix it. Any help would be greatly appreciated.
Thanks everyone for your help. After trying all of your suggestions I found a Google group and logged the issue. Google have responded to it as follows:
David Newgas: For now try connecting from a GCE instance (including cloud shell) or using a GCE instance to proxy connections from your laptop.
I have updated the dashboard with some more information (although it may take a while for you to see it due to caching)
To be clear, this issue will only be affecting first generation instances.
I did not have enough 'points' to comment, so I'll have my say here.
I am having about exactly the same issue. About 10 days ago I connected fine to the Cloud SQL instance, and synced my db up. Yesterday I was going to push some updates etc. But I could not connect, even though I have changed nothing in respect to the database connection, except for the given IPv4.
I figured the issue was with my Django project, based on the App Engine Skeleton, so I created an issue on that project.
https://github.com/GoogleCloudPlatform/appengine-django-skeleton/issues/16
Maybe/Hopefully some we get some information from there.
I had the same problem.
By pure luck I said "Let's try to connect with my local MySQL client while the gcloud command was saying
"Whitelisting your IP for incoming connection for 5 minutes..."
and (mysql local client) worked.

Can't connect to RDS after changing size

I have an RDS instance that I was able to connect to remotely fine for months now. However, tonight I downsized the DB because we we're paying for a lot of unused CPU. After the change from m3.medium to the t2.small I can't connect to it anymore. I have terminal shortcuts setup so I can't be typoing it. I double checked the security groups and thats still applied and the host is the same and everything. I'm not sure what else to try. I just get:
ERROR 2003 (HY000): Can't connect to MySQL server on '<my-host>.us-east-1.rds.amazonaws.com' (60)
I encountered the same problem today. After upsizing the RDS instance, I am unable to connect to it using SSMS which I was able to do just a few hours earlier. It has suddenly stopped working on two PCs so I could not have accidentally changed some parameters. However the web server accessing the RDS within the VPC works fine
sorry for silly question: are you sure my-host didn't change after resizing? Given the error message, it's not credentials. So, it is either address, or security groups, or VPC-based networking.

MySQL server on Amazon RDS not reachable from only one host

I have multiple hosts that connect with a database on an Amazon RDS server. The normal webservers have no trouble connecting with the database, but today I discovered that my development server couldn't connect.
The error I get is
'ERROR 2003 (HY000): Can't connect to MySQL server on
'endpoint.blabla.rds.amazonaws.com' (113)'
Trying to connect via my home laptop gives no problems. It's only the devserver.
When I initiate a connection from the devserver via nc, it gives 'No route to host'. As far as I know, I didn't change anything on the devserver. The databaseserver however has been resized last Thursday, but I'm not sure when the problems have started. I know that it still worked two weeks ago, that's all.
Anyone any experienced this before with Amazon RDS? I really don't know where to look at the moment. The VPC security groups haven't changed, and other servers with the same security groups on the same VPC have no trouble connecting to the database.
Ok it is solved after a couple of hours searching. There was a route in my route table that caused the trouble. I have no idea how it got there, but it is solved now, I can reach the server again. :)