0

I have a vagrant box running on my windows machine. I want to make use of the command grunt serve. When running grunt serve, I want to access the site on my host machine as I have no browsers on the vagrant box. How would I acomplish this?

I have identified the port in the grunt file. At the moment that is set to 9000. However that is also in use by php as I have other apps using laravel (the box is homestead).

Usually I access my site at mysite.dev as I have set up hosts file and a homestead.yaml to map to the box. In that file I also see:

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

mysite.dev is nice but localhost:9001 or anything else is also fine. How should I proceed?

ajthinking
  • 3,386
  • 8
  • 45
  • 75
  • 1
    the ports are commented and would be needed if you dont setup a static IP but as you said you set up hosts file I assume you have a static IP for the VM and if configured with your host file on mysite.dev you should be able to access mysite.dev:9001 (if its the port where grunt is running) – Frederic Henri Apr 11 '17 at 07:14
  • Thanks! So I got grunt serve to run on port 9123, but still cant access mysite.dev:9123 as it sais ERR_CONNECTION_REFUSED. So I guess VM is not exposing that port? – ajthinking Apr 11 '17 at 13:55
  • netstat confirms grunt is using the port. – ajthinking Apr 11 '17 at 14:01
  • which version of grunt are you running ? did you change [`hostname`](https://github.com/gruntjs/grunt-contrib-connect#hostname) by default set to 0.0.0.0 so should work, you can try changing by the IP but 0.0.0.0 binds to all network interfaces – Frederic Henri Apr 11 '17 at 14:11
  • Im stuck in grunt "^0.4.5" for various reasons. But its serving. I got the static IP so that would still be the same right? But I seem to be locked out of the port. Even though provisioning sais: homestead-7: 9123 (guest) => 9124 (host) (adapter 1) – ajthinking Apr 11 '17 at 14:31
  • no the change in grunt was made in 0.7.1 (https://github.com/gruntjs/grunt-contrib-connect/commit/1373ea98b0ee13144754d249eb3b026b4215d152) it allows to listen on 0.0.0.0 so you need to change the hostname (https://github.com/gruntjs/grunt-contrib-connect#hostname) property in your grunt config to be `0.0.0.0`` or your IP address – Frederic Henri Apr 11 '17 at 14:42

0 Answers0