I’m trying to configure debugger for my web application, but I run into trouble with specifying correct ports for it.
Vagrantfile:
config.vm.network :private_network, ip: "192.168.68.8"
config.vm.network :forwarded_port, guest: 80, host: 8080
/etc/hosts (on my host machine)
192.168.68.8 mysite.com
I installed these two gems for debugging
gem 'ruby-debug-ide', group: [:development,:test]
gem 'debase', group: [:development,:test]
I read that in order to use ruby-debug-ide on vagrant, I should run
rdebug-ide --host 0.0.0.0 --port 80 --dispatcher-port 8080 -- bin/rails s
where --port should be guest port from Vagrantfile and host port for `--dispatcher-port``
But it says
Permission denied - bind(2) for "0.0.0.0" port 80
On the other side, if I try to change those ports in Vagrantfile, I lose the opportunity to reach my application from 127.0.0.1:specified_port, but still can do it from mysite.com, which is confusing
you already have something listening on port 80 (apache or nginx) so you cant bind on this port. You can do one of the following
in your vagrant start
rdebug-ide --host 0.0.0.0 --port 3000 --dispatcher-port 3000 -- bin/rails sIf you use a private network IP in your vagrantfile you dont need to forward port as you'll access your VM server using its own IP
run
sudo netstat -nltpin your VM, check the process which binds the port 80 and kill itFor example
so you'll kill the apache2 process (PID 1827)