Stable SSH port forwarding

I have a MySQL database in AWS and access it through SSH port forwarding. Before connecting to the database, I need to run the following command:

ssh -o ServerAliveInterval=60 -o StrictHostKeyChecking=no -i /myapp/some.pem -L 3306:db-domain.com:3306 user@ec2-public-ip-address -p 22

It works fine immediately after deployment, but after a few days (or sometimes just a few hours), the connection to the database is lost because the SSH port forwarding disconnects. I’ve placed the above command in start.sh or include it in the "start" script in package.json, but neither method is reliably stable. Where should I put this command to keep it running without problem?

Any suggestion would be appreciated. Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.