Skip to content

Instantly share code, notes, and snippets.

@neilk
Created August 22, 2013 18:42
Show Gist options
  • Save neilk/6311127 to your computer and use it in GitHub Desktop.
Save neilk/6311127 to your computer and use it in GitHub Desktop.
SSH into a Vagrant VM, such that Node.js can be debugged from a debugger or IDE in the host operating system. For some reason, port forwarding in the Vagrant file does not work. See https://groups.google.com/forum/#!topic/vagrant-up/RzPooJ0dp6Q
#!/bin/bash
# SSH into a Vagrant VM, forwarding ports in a way that allows node within Vagrant to be debugged by a debugger
# or IDE in the host operating system. Don't know why, but Vagrantfile port forwarding does not work.
# (https://groups.google.com/forum/#!topic/vagrant-up/RzPooJ0dp6Q)
/usr/bin/vagrant ssh-config > $TMPDIR/vagrant-ssh-config
ssh -F $TMPDIR/vagrant-ssh-config -L 5858:127.0.0.1:5858 default
rm $TMPDIR/vagrant-ssh-config
@drewsonne
Copy link

I update this to take an argument as an arbitrary port, https://gist.github.com/drewsonne/747b1ce77cc2f912af0f

@Mastergalen
Copy link

By default node-debug will bind to 127.0.0.1 which is loopback.

Use node-debug --web-host=0.0.0.0 to bind it to all interfaces. Forwarding port 8080 should now work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment