MacOS – How to use Torify for an App on OS X

command linemacosPROXYtor

I want one of my applications to use Tor; however the app itself does not have proxy setting and it uses the System proxy. The problem is that I don't want to set my system proxy and I just want this one application to use tor.

I searched a bit for a solution, I came up with torify. I have installed tor and torify using brew and everything works fine and for example I can force curl to use tor like this: torify curl ifconfig.me 2

To use torify, I need to start my app from Terminal. For this, I use open -a myapp. However, this does not make myapp to go behind the tor proxy.I think it's because of the open command and I think I have to open myapp somehow directly. By the way, myapp does not work when I try to run it by opening the executable file inside the /Contents/MacOS folder.

Do you guys have any suggestion?

Thanks in advance

Best Answer

Tell your command where your myapp.app resides

You need to provide the open command an absolute or relative path to the application, unless the executable is already within your $PATH, or you change your working directory to the location in the filesystem where your myapp.app is (in my examples, myapp.app is the Applications folder, the home Applications folder, a folder called someotherplace, and the Shared folder, respectively).

 open /Applications/myapp.app
 open ~/Applications/myapp.app
 open ../someotherplace/myapp.app
 cd && cd ../Shared/ && open myapp.app

You can also type your open command and hit spacebar, and drag your application from anywhere into the Terminal, and the path will be provided.

There is another way

You can execute your executable using its full path and adding the ampersand. This will run it in the background so your terminal isn't tied up:

 ./myapp.app/Contents/MacOS/myapp &
 /Applications/myapp.app/Contents/MacOS/myapp &
 cd /Volumes/externaldisk/projects/thisone/myapp.app/Contents/MacOS && ./myapp &

And interestingly, using this method you can launch as many instances of your app as you have memory to do so.

To use torify with your myapp.app

I'm reasonably sure you need to launch it like this to use torify (assuming your myapp.app is in the /Applications folder):

 torify /Applications/myapp.app/Contents/MacOS/myapp &

or

 cd /Applications/myapp.app/Contents/MacOS/
 torify myapp &