0

I'm trying to access a website on a vagrant box (Laravel Homestead) through port 8000 on my host but it always gives the ERR_CONNECTION_REFUSED error on Chrome and IE.

I have tried multiple setups, change host and guest configs (NIC's, firewalls, etc.) but I'm getting desperate! I know I pulled it off in a Windows 7 machine some time ago but now I can't remember how I did it.

Anyway, I'll try my best to describe my current home network if it helps. I have two routers A and B. Router A is the ISP's router and has the DHCP service (192.168.1.50 - 192.168.1.254) and firewall in medium settings. Router B is in my bedroom and connects with router A through ethernet cable. It has DHCP off and the gateway is the IP of router A. My host machine can connect via ethernet or wireless to router B. On the routers side I've only tried to disable the firewalls with some settings I tried.

My host machine is running Windows 8.1 64 bit and the guest OS is Ubuntu Server 14.10 64 bit. The vagrant box configured the NIC's for me. NIC 1 is NAT with various port forwarding configs (notably ssh->2222->22, tcp8000->8000->80). NIC 2 is Host-only with IP address 192.168.10.10, subnet mask 255.255.255.0.

Everything works fine (SSH) until I try to access the already configured website through port 8000 in the host's browser (http://192.168.10.10:8000). It always gives that error.

I checked Virtualbox's configuration (initially vagrant or virtualbox has a bug where the IP of NIC 2 was incorrectly set as 192.168.10.1, which I corrected after but still no gain). I've tested with different subnet mask (255.255.0.0). I've disabled all router firewalls, checked Windows's firewall too. I've googled this all over the place. Tried different private network IP's. I've edited the etc/network/interfaces config file on the guest, tried troubleshooting or checked: iptables, route -n, netstat -rn... Ping does work from host to guest and vice-versa. But telnet 192.168.10.10 8000 from host machine says the connection was refused.

I even tried to disable my wifi and connect my machine through ethernet cable although, and correct me if I'm wrong but, my home network should not have anything to do with this situation right?

I'm really starting to lose hope on this, it's getting really frustrating!

Any help will be most welcome!

2
  • I suspect that this is not an issue with the OS. Check your network routing settings and also check whether you are able to ping and telnet the website from your network.
    – BDRSuite
    Jan 16, 2015 at 13:55
  • I can ping fine both ways. Telnet from host to guest at 192.168.10.10:8000 shows no error, just a blank screen (so I'm assuming it is connecting). But can'y access the website through browser. What else should I do/troubleshoot?
    – tiagosv
    Jan 19, 2015 at 22:05

1 Answer 1

0

I had this very same issue just a min ago on two computers (windows 8 and windows 10), what I did is run "vagrant up && vagrant ssh", followed by:

netstat -ntlp | grep LISTEN

And compared this with someone on Laravel's IRC channel, first thing that caught my attention is that I was missing this nginx entry on the netstat output:

tcp        0      0 0.0.0.0:80              0.0.0.0:*   4/nginx: worker

What I was doing wrong, was that I was using vagrant commands (possibly incorrectly), so what worked for me was using homestead commands instead:

homestead init
homestead up
homestead ssh
#homestead halt, homestead provision, homestead destroy, etc...

stick to these commands and you should be allright, also remove any old vagrant and homestead boxes from your virtualbox applications.

If everything went allright localhost:8000 and 192.168.10.10 should display: "No input file specified"

EDIT 1: I found out the issues are related to the Vagrantfile, even though I ran:

rm Vagranfile
vagrant init laravel/homestead
vagrant up

Somehow the configuration is missing port-forwarding and probably a lot of other configurations.

EDIT 2: I also found out that "homestead ssh" seems to be buggy and can cause backspace problems, which are captured as spaces, if this issue affects you use the following command to logon:

ssh vagrant@localhost -p 2222

Let me know if my reply helped solve your issue

3
  • Thanks for your reply but it didn't work. How do you get "homestead" to act as a command? It's obviously not a command in Windows CMD. There is a homestead.rb file in the scripts folder. Do you run the ruby interpreter on it?
    – tiagosv
    Mar 10, 2015 at 1:12
  • I assume you haven't properly installed homestead, run composer global require "laravel/installer=~1.1" When this command starts executing you will see the folder where it downloads too, in my case: ~/AppData/Roaming/Composer/vendor/bin. So it's nexessary to add this path to the environment variables of either Git Bash or Windows. To do this run: sysdm.cpl inside windows > click Advanced [tab] > click Environment Variables... > click Path (EDIT) > add ;%APPDATA%/Composer/vendor/bin. Close Git Bash and reopen, after this the homestead command should be available.
    – reconx86
    Mar 11, 2015 at 21:54
  • Also make sure you have run this command vagrant box add laravel/homestead so that the homestead box is actually available on your system
    – reconx86
    Mar 11, 2015 at 22:03

You must log in to answer this question.

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