Why is connection refused by Vagrant box in Windows 10? - apache

I've been having problems with Vagrant since upgrading to Windows 10. At first I had the "host-only adapter" problem that many people seem to be experiencing. This was fixed by updating VirtualBox to the latest version, and my Vagrant box now seems to provision and start ok, and I can SSH into it, but can't connect via HTTP. If I try to access it from a browser, I get "Unable to connect". If I try curling it, I get the message:
Failed to connect to test.dev port 80: Connection refused
I've checked and Apache seems to be running on the VM (and in fact if I SSH into the VM and then run curl 127.0.0.1 the expected homepage is returned). At this point I've drawn a blank: I don't know whether the problem is in Windows or the VM's settings. Any help would be greatly appreciated!
(For what it's worth, I'm using VirtualBox 5.0.15r105158 + Vagrant 1.8.1)
Update: it turns out that the VM is accessible from test.dev:8888 in the browser, so I'm guessing the problem is to do with port-forwarding? I don't know much about this though, so have no idea why this wouldn't be working in Windows 10. (In case it helps, my Vagrantfile contains the line config.vm.network :forwarded_port, guest: 80, host: 8888)

I think you have answered all by yourself - you might read the vagrant doc on port forwarding
Vagrant forwarded ports allow you to access a port on your host
machine and have all data forwarded to a port on the guest machine,
over either TCP or UDP.
For example: If the guest machine is running a web server listening on
port 80, you can make a forwarded port mapping to port 8888 (or
anything) on your host machine. You can then open your browser to
localhost:8888 and browse the website, while all actual network data
is being sent to the guest.
when you add the line config.vm.network :forwarded_port, guest: 80, host: 8888 to your vagrant file, the VM (i.e. call also guest or guest VM) )will forward all the stream going on its port 80 to the host (in you case the windows machine) on port 8888, so in this case when you point your browser to listen on port 8888 you can see the website running from the VM
When you are within the VM though, you point to the expected 80 port.
one additional point (hope not to confuse you): in your Vagrantfile, did you define something for networking ? (param config.vm.network) you probably define a fixed IP (since you point to test.dev) in such case you dont need to do port forwarding, you can correctly access http://test.dev (on default port 80) as nothing else is bounding to this port. Port forwarding is really useful when you use public network and you do not define a fix IP to the guest VM, so in this case you access the site running on the VM from localhost/127.0.0.1, and as such you cannot just point to port 80, as something on your host can already be running.

Related

Metasploit handler failed to bind to port 4444

I am running Kali Linux on VMware. The host operating system is windows 7, and I'm using NAT for connectivity.
In my metasploit console, when I typed 'exploit' at the msf prompt,(where I am using windows/meterpreter/reverse_tcp as the payload) it showed me the error
Handler failed to bind to My IP:4444
(My IP is my external IP address.)
So in the VMware virtual network editor, I have port forwarded port 4444 of host PC to port 4444 of the virtual PC. Then I allowed inbound packets in the firewall of the host PC, for port 4444 of the host PC.
To ensure that everything is alright, I set up an apache server on the virtual PC, that serves a webpage when accessed via port 4444. The server served flawlessly when I accessed it with an external browser. Satisfied, I shut down the server.
But guess what? Metasploit console has thrown up the same error when I typed 'exploit' again in the msf prompt.
What to do now?
What did it say the reason for failing was.
I'm assuming the full error was failed to bind to port 4444 port is already in use.
You can not run a server on the same port you are trying to bind to.
The correct way to do this is to port forward through your router. Open your router settings and port forward port 4444 to your machines local ip.

Static IP, PI. raspbian jessie

Okay, here's the situation I am in. I have a raspberry Pi 2 model B. I have Raspbain Jessie installed as the OS. I have Apache installed as well. I have a web server running and i am able to edit it and access the site from different devices on different internet connections. I want to be able to connect to my RaspPi through SSH on my MacBook Pro. I am able to do this while on the same network. My Pi is plugged into the router via an Ethernet. What i have tried is, logging into my router and reserving an IP for my Pi, i also entered my MAC address here. I have gone into the port forwarding options in my router and have it set up as: HTTP, TCP, Server address(the one i reserved) my Ipv6, and Start port 80, end port 80. Ontop of that i have gone into my /etc/dhcpcd.conf file. There at the end of the file i added
interface eth0
static ip_address=10.0.0.100
static routers=10.0.0.1
static domain_name_servers=68.44.180.118 2001:558:feed::1 2001:558:feed::2
The guide I followed is attached here and follows other guides i have seen.
http://www.circuitbasics.com/how-to-set-up-a-static-ip-on-the-raspberry-pi/
Yet when i try to SSH remotely i cannot get a connection, and when i connect on the same internet i can connect as normal. Please if anybody sees what could help .
Your router's firewall is probably blocking the ports for SSH, which does not use port 80 (in raspbian, I think its default is port 22). If you are going to take the risk of leaving your SSH open to the public, you should probably switch it to a different port other than the default before opening up a port on your firewall. The Raspbian Community has a thread on how to properly change SSH's default server port. You'll also need to make sure your SSH client is using the same port. You will need to leave 80 open for web, and also forward the SSH port, which ever you choose that to be (22 is the default).

I cannot access the default Apache webserver page, which is hosted in a VirtualBox VM, from my machine

My machine is a regular laptop with Windows 7. I have a Virtualbox VM running Ubuntu Server 14.04.1 and I have apache2 installed. When I try to access the default webserver page (10.0.2.15) from my machine, it cannot find the page. I have disabled my machine's firewall so that isn't causing the issue. The network for my VM is NAT, but I also tried the bridged adapter setting to no avail. Any suggestions would help.
Can you ping the server? If so, try the netstat command in server terminal to determine if it listens to port 80. If you cannot ping it, check the network address, f.x with ifconfig
If you can ping apache from the server, you probably have a problem with the network.
Try to add an host only interface. Then, in your VM, sudo ifconfig. Use the eth1's ip.

Port forwarding on VirtualBox

I have to set up a Virtual Machine on vBox that works as a server for my app. Now, the app sends data to http://x.y.w.z:4567. I run apache server on host and wireshark confirms that the packet is received. Guest is behind NAT and is set up to forward TCPs from any IP port 4567 to port 443 on guest. I tried various versions of setting and not setting IP. Guest also has apache running, but it receives no packets. What should I do?
Please check the log that your port-forward rule is active. Also that your guest/host firewalls doesn't drop packets.

Apache is running on Port 80 but can't connect remotely

I have Apache installed on Windows 7. It's running successfully - I can connect to it from the local host. The problem is that none of the other computers on the local wireless network don't connect.
I have configured the \apache\conf\httpd.conf to "Allow from all" and to "Listen 80"
I disabled the Firewall for Port 80
Also, the command netstat -abn shows:
TCP 0.0.0.0:80 0.0.0.0: LISTENING
Can anyone think of a reason that prevents me to connect from another machine?
Try using the repair option on the firewall - sometimes the wizard there will add additional rules which resolve the issue.