2

So I have a NGINX server listening on port 8080 with uwsgi on Vagrant box. The config.vm.forward_port 8080, 80 is not working for me. I know that it's recommended to forward on ports higher than 2000, but I need the 80. Is there any issue for that?

I'm using vagrant for development, but I need to make some tests from outside using my domain name on port 80. Thanks for your help.

ScotchAndSoda
  • 3,811
  • 4
  • 34
  • 38

2 Answers2

9

When trying to forward ports to less than 1025 vagrant gives me following message which you might have missed:

You are trying to forward to privileged ports (ports <= 1024). Most operating systems restrict this to only privileged process (typically processes running as an administrative user). This is a warning in case the port forwarding doesn't work. If any problems occur, please try a port higher than 1024.

I was using port forwarding to same port with following configuration:

config.vm.forward_port 80, 80

And then run vagrant up, but when trying curl localhost, it wasn't able to connect to host. But when running vagrant as sudo user sudo vagrant up, then I was able to access the port from my host.

  • well, could you explain me please why is this working by forwarding 80 to 80, but not with 8000 to 80? In the two case I vagrant up & ssh as sudo? – ScotchAndSoda Jan 09 '13 at 21:45
  • Have you tried to forward the port to other than 80, like 9000? Is it working then? One reason could be that the port 80 is reserved by your host already. – Mikael Kundert Feb 21 '13 at 08:09
1

is port 80 available i.e. if you run netstat -an | grep 80, does it show in the list as already being used by another process? Is uwsgi added to the module list of nginx (and did you run make/make install on it)? Have you tried checking if you need to use higher privilenges (perhaps try running as sudo).

ali haider
  • 19,175
  • 17
  • 80
  • 149
  • well, NGINX is properly configured with uwsgi. if I make it listen on port 80 and forward the port 80 to 8080 on vagrant, NGINX is responding. The opposite doesn't work. Otherwise netstat -an | grep 80 is giving me a long list, seems that my 80 is used by other processes. What could I do in this case to have my vagrant port 8080 to 80 responding? – ScotchAndSoda Jul 05 '12 at 10:57
  • wondering - are you able to use the setup with another port? if so, two things come to mind that I would check for - either the port 80 is not available (bound by another service) or perhaps more likely, you need to run the process as sudo user. – ali haider Jul 05 '12 at 11:53
  • 1
    Similar question has been answered here before: http://stackoverflow.com/questions/10953070/how-to-debug-vagrant-cannot-forward-the-specified-ports-on-this-vm-message – Vishal Biyani Jul 05 '12 at 17:01