23 days ago
I'm new to Railway and I can't say for sure if the problem I'm experiencing has been there from the start.
I have two separate environments (staging/production) of the same application. The problem I described only occurs in production; the staging version is fine (even though the production environment was created using a copy of the staging environment).
The problem is this: after some deployments, the SvelteKit service (Node.js) loses its connection to the MySQL service. The DATABASE_URL variable is used by the application (via Prisma ORM), and the value "${{MySQL.MYSQL_URL}}" is used.
It seems to me that the scenario is as follows:
- If no migration is performed (npm run db:deploy has no effect), the connection is stable.
- If a migration occurs, whether successful or not, the connection is lost. - The problem can also occur if I change an environment setting and redeploy the service.
- The MySQL service remains operational and accessible (remotely, via CLI, or from the interface).
The error is visible in the application logs as a Prisma error (before deployment):
- Error: P1001: Can't reach database server at mysql.railway.internal:3306
In the HTTP logs (if deployed):
- failed to retrieve a connection from pool after 10000ms (pool connections: active=0 idle=0 limit=10)","name":"DriverAdapterError","cause":{"originalCode":"45028","originalMessage":"pool timeout: failed to retrieve a connection from pool after 10000ms (pool connections: active=0 idle=0 limit=10)","kind":"mysql","code":45028,"message":"pool timeout: failed to retrieve a connection from pool after 10000ms (pool connections: active=0 idle=0 limit=10)","state":"HY000","cause":"(conn:126, no: 45044, SQLState: 08S01) RSA public key is not available client side. Either set the cachingRsaPublicKey option to indicate the public key path, or allow public key retrieval with the allowPublicKeyRetrieval option.
In the network logs:
- NO_SOCKET, see flowId "b205ed98-8e9c-4e43-95f6-47e8f253cc72"
I want to clarify that the problem is not related to the migrations; I can verify in the database that they were successful.
This has happened to me several times, and each time the connection was restored after trying to change environment settings and redeploying/restarting the service multiple times. I still don't understand why.
3 Replies
23 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • 23 days ago
23 days ago
Yes it is.
It may have something to do with allowPublicKeyRetrieval variable.
After a few restarts and playing around with this variable, I got the connection back.
Why would it be necessary (allowPublicKeyRetrieval=true) in production and not in staging?
4 days ago
Any clue? It seems that keeping allowPublicKeyRetrieval=true solves the problem. It is not necessary in staging, though.