Search code examples
macosssh-tunnelvnc-server

How to reconnect to lost VNC server on mac


I'm using ssh tunneling, vncserver, and the default Mac Screen Sharing app to run a GUI on a remote server (university clusters). It works really well in general, but often if left too long or after moving my laptop to another wifi network (eg, from home to campus) I lose connection to the remote server and Screen Sharing gets stuck in the "Reconnecting" forever.

It appears that the GUI is still running on the remote server because when I write vncserver -list in ~/.vnc it still has the .pid file (and I never used the -kill command). How can I reconnect to this vncserver? When I enter vnc://localhost:59xx in Screen Sharing it says

Connection failed to "localhost".

Make sure Screen Sharing or Remote Management is enabled on the remote computer

I'd really like to reconnect to this remote server because I'm running time-consuming and time-sensitive processes that I need to check the status of from time to time, and I need to make sure that the program successfully saves the output of my program.

Thank you!


Solution

  • Figured it out. I didn't realize that the localhost was based on my IP address, so when I moved locations the ssh tunnel collapsed. All I had to do was recreate the tunnel (ssh -L 59xx:localHost:59xx -N -f [email protected] and I was able to reconnect to the port with Screen Sharing.