0

I look for solution in my Laravel application. I have database on another server and try co connect it with my app. I am not sure how to set .env file and how to set and keep connection between servers.

I read about approach with ssh connection:

ssh -fNg -L 3307:127.0.0.1:3306 myuser@remotehost.com
mysql -h 127.0.0.1 -P 3307 -u dbuser -p db

and that works but after one day connection expires and again I have to set the connection on server. I need to keep it.

Do you have solution?

Adam Kozlowski
  • 5,606
  • 2
  • 32
  • 51
  • 1
    https://stackoverflow.com/questions/25084288/keep-ssh-session-alive – online Thomas Jan 05 '18 at 10:03
  • I read and tried that, but how can I check does it work? How to change server expiration of ssh connection? – Adam Kozlowski Jan 05 '18 at 10:04
  • Well, why don't you try playing with the expiration? First try 1 minute, does it work? Then 10 minutes etc. – online Thomas Jan 05 '18 at 10:05
  • I played a lot. Look, now by default I guess expiration is 12 hours, because connection works all day. After night it does not work. So i look for place to change it on apache. Do not where. – Adam Kozlowski Jan 05 '18 at 10:06
  • If this mysql is not public, why don't you just allow the IP address of your Laravel application to connect to it? – fab Jan 05 '18 at 10:10
  • I receive: SQLSTATE[HY000] [2002] Connection refused . I set DB_HOST=XXX.XXX.X.XX DB_PORT=3306, maybe port is wrong but do not know how to check it – Adam Kozlowski Jan 05 '18 at 10:14

0 Answers0