I am trying to connect to a remote MySQL database on an Ubuntu 18.04 server using a putty tunnel on my Windows 10 home computer.

Using putty, I can connect to my Ubuntu server terminal via SSH. This step is fine. I then add a tunnel that uses local port 3307 and points to port 3306 on the remote server. (screenshot below).

enter image description here

Then, when I run the putty session, I would expect that I could open a database tool, like DBeaver, and create a connection to localhost:3307 and that would connect me to the remote server's MySQL database on 3306. When I try this, I get an error. Am I missing a crucial step?

I know there are other ways to connect to the remote database (including a built-in SSH tunnel in DBeaver, which, for the record, works fine!), but I need to use a putty-like SSH tunnel for the workflow I'm trying. DBeaver was just an example that shows the same error as my programmed workflow. So please keep your support relative to that train of thought, thank you.

enter image description here

Putty Event Log

2019-01-15 10:47:02 Connecting to 159.###.###.74 port 22
2019-01-15 10:47:02 We claim version: SSH-2.0-PuTTY_Release_0.70
2019-01-15 10:47:02 Server version: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1
2019-01-15 10:47:02 Using SSH protocol version 2
2019-01-15 10:47:02 Doing ECDH key exchange with curve Curve25519 and hash SHA-256
2019-01-15 10:47:03 Server also has ecdsa-sha2-nistp256/ssh-rsa host keys, but we don't know any of them
2019-01-15 10:47:03 Host key fingerprint is:
2019-01-15 10:47:03 ssh-ed25519 256 ##:##:##:##:##:##:##:##:##:##:##:##:##:##:##:##
2019-01-15 10:47:03 Initialised AES-256 SDCTR client->server encryption
2019-01-15 10:47:03 Initialised HMAC-SHA-256 client->server MAC algorithm
2019-01-15 10:47:03 Initialised AES-256 SDCTR server->client encryption
2019-01-15 10:47:03 Initialised HMAC-SHA-256 server->client MAC algorithm
2019-01-15 10:47:10 Sent password
2019-01-15 10:47:10 Access granted
2019-01-15 10:47:10 Opening session as main channel
2019-01-15 10:47:11 Opened main channel
2019-01-15 10:47:11 Local port 3307 forwarding to 159.###.###.74:3306
2019-01-15 10:47:11 Allocated pty (ospeed 38400bps, ispeed 38400bps)
2019-01-15 10:47:11 Started a shell/command
  • What does PuTTY even log say? What is 159....74? – Martin Prikryl Jan 15 at 15:26
  • That's my remote server IP. I blurred some of it for privacy. I don't see anything in the Event Viewer for Putty. I did see a putty.log file but it only shows what my terminal session text shows so it's unrelated to the tunnel. – Frantumn Jan 15 at 15:37
  • I've asked for PuTTY event log (right click PuTTY window caption) + Did you try localhost instead of the IP, as you are connecting to the server itself? – Martin Prikryl Jan 15 at 16:12
  • @MartinPrikryl Thank you for explaining where the log was. I didn't ever know that was there! I've added the log to my post. I've replaced some numbers with # again, for privacy. And yes, I've tried using localhost instead of the remote server IP. It doesn't work. – Frantumn Jan 15 at 16:22
  • @KamilMaciorowski That did it! I had tried localhost:3306, as mentioned above, but not After trying that it worked. Thank you! Feel free to make that the solution if you want. – Frantumn Jan 15 at 16:43

In putty, my forward destination should have been instead of the public IP. I tried using localhost:3306 and that didn't work. It had to be because that was all that MySQL was set to listen to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.