The title is pretty much self explanatory

If a SQL server only allows connections from localhost, is there any way I can access from the outside by making it think I'm actually accessing from localhost?

  • is ssh an option?
    – dandavis
    Nov 29, 2016 at 19:36

2 Answers 2


Obvious answer: Make a local connection.

In other words, unless the network stack (of the operating system) is buggy, or someone grossly misconfigured e.g. port forwardings on the machine your database runs on, the only way to do that is by actually opening a connection from the machine your database runs on itself.

Now, in the year 2016, I'd say it'd still be totally unacceptable to offer unauthorized access based on host alone – you simply don't do that, since there's no cost to authentication.

A proper way of doing "safe" local-only networking is to not use IP sockets, but good ol' unix sockets, which can be secured using normal file access privilege systems.


You can create a tunnel. With SSH on Linux, that would look something like ssh -TNL "3306:localhost:3306" user@server. This would make the port 3306 on your computer connect to the remote computer (via port 22), and forward all its packets to the port 3306 on that computer as if they came from its localhost.

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.