Is it possible to specify which network device should be used when running something in the Terminal? Like

$ rails [only communicate through deviceA]

Not just app, but instance specific, so different instances of rails could use different network devices. Alternately, could it be done by port? So localhost:3000 would use deviceA, while localhost:4000 would use deviceB, etc.

  • 1
    Wouldn't you configure this inside your rails app? Basically poll the OS for all network connections and then only listen on the one(s) you prefer?
    – bmike
    Nov 25, 2014 at 19:49

1 Answer 1


Could you just create a local web proxy to run it through? You could create one using something like this command in the terminal:

networksetup -setwebproxy "Network Service 1 Name" proxy2.domain.com 3000

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .