Error:
peewee.OperationalError: (2003, "Can't connect to MySQL server on 'containers-us-west-205.railway.app' (timed out)")
When it occurs:
After everyday, or so.
Account on railway:
Paid
Dev Frameworks:
Flask, MySQL as Backend
Railway dashboard:
Shared varaibels are directly from the mysql instance on dashboard:
Works fine, just have to restart database every once in a while, why is that?
MySQL's docs for error 2003 state:
The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.
Peewee is passing you the error from pymysql, which is indicating that your application timed-out attempting to connect to the MySQL server.
I would reach out to your host to see what the issue is, and why the MySQL server is unreachable. You can also try:
app.before_request
and closed in app.teardown_request
callbacks.connect_timeout
, e.g. MySQLDatabase(..., connect_timeout=x)
(default is 10s).