Empty reply from server - can't connect to vagrant vm w/port forwarding - vagrant

I'm running werkzeug (as part of a Tilestache setup) inside a Vagrant VM, running ubuntu 'precise.'
In my Vagrantfile, I have:
config.vm.network :forwarded_port, guest: 8080, host: 8080
When I start the server in the VM, I see:
* Running on http://127.0.0.1:8080/
If I curl that address from within the VM, I get the expected result. When I curl it from the host machine, I get:
curl: (52) Empty reply from server
And Chrome says "No data received."
Troubleshooting info:
The server responds to pings from the host machine
a port sniffer verifies that the port is open
running netstat -ntlp | grep 8080 in the vm shows that the server is listening on 8080
My local hostsfile doesn't have any weird conflicts
I'm also forwarding 22 => 2222, and I can ssh in with no trouble
I've disabled the firewall on the host, and i don't believe there's one on the guest (iptables and ufw are disabled, at least)
I've set auto_correct: true in case there are conflicts (there aren't)
I know I could set up a private network, but I'd like to understand why this isn't working and how to troubleshoot it.
Any other ideas?

When running a server from within a VM, start the server on 0.0.0.0 instead of 127.0.0.1.
127.0.0.1 is only accessible to the local machine, which for a VM means nothing outside of the VM can reach it! 0.0.0.0 is accessible from anywhere on the local network, which to a VM includes the host machine.
The answer came from here: Connection Reset when port forwarding with Vagrant
(Which apparently got its answer from here: https://stackoverflow.com/a/5999945/738675)
With help from: https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1
Google-bait:
Here are the errors you might receive if this is the problem:
Chrome: "No data received"
Firefox: "The connection was reset - The connection to the server was reset while the page was loading."
Safari: "Safari can’t open the page [URL] because the server unexpectedly dropped the connection"
curl: "Empty reply from server"

In the /etc/hosts inside the VM, change line
127.0.0.1 localhost -> 0.0.0.0 localhost
and then restart server

This can also be a problem with your firewall on the vagrant machine. If you can curl the address while on the vagrant box, then check your firewalld settings or turn it off:
on CENTOS:
sudo service firewalld stop
Then you should update your firewalld settings and restart it ;)

Related

Cannot access application running on JBOSS EAP 7 outside vagrant box

I am actually trying to access the application outside the vagrant box which is running on JBOSS EAP 7 server on port 8080. I did add the settings for port forwarding in vagrant file that is
config.vm.network :forwarded_port, guest: 3000, host: 8080
Port forwarding does shows in terminal log when i reloaded the vagrant. However when i access the application from browser outside of the vagrant box am getting error as ERR_CONNECTION_REFUSED on the browser. I also binded the address to 0.0.0.0 by running the below command but still no luck. Any suggestions please what i may be missing? I also did set the proxy settings but still no luck.
sudo ./standalone.sh -b 0.0.0.0
Below is the port binded with 0.0.0.0
Below is the log for my vagrant reload
Below is the port forwarding i set in my ubuntu vagrant box
Below is the error on the browser
I found something that could help.
I'm using a RHEL 7.6 and the firewall was on:
$ sudo firewall-cmd --state
running
After disabling:
$ systemctl stop firewalld
$ sudo firewall-cmd --state
not running
I successfully access Jboss console from the outside

Cento 7 Firewalld refuses all incoming connections to my web-server

I have Centos7 VM built using vagrant with private IP address of:192.168.56.255
I am running my Spring boot application on that VM on port 8443. It supports HTTPS. My issue is that when try to send https requests to 192.168.56.255 web server via Curl command i got
curl: (7) Couldn't connect to server
I have read many tutorials that explain how to configure my Firewall in Cento7 but still got the same issue one is provided by DigitalOcean
When I type
sudo firewall-cmd --list-all-zones
I got
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh dhcpv6-client https http mysql
ports: 8443/tcp 3306/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
As you can see I enabled everything I need and more but still. I even shut down the Firewall but still the connection is refused from my host.
When I made the changes I did reload my firewall
sudo firewall-cmd --realod
So that is not the problem
The problem was not with the Firewalld but with the pre-configured IP address using Vagrant.
The IP address should not be 255 in the first byte as I did 192.168.56.255
because that indicates that this is a broadcast address. So i solved it by changing it to 192.168.56.10

Vagrant + Xdebug + Atom

I have a vagrant box with xdebug installed, running on OSX, but Im struggling to get the Atom xdebug plugin (php-debug) to connect to it.
I pasted the phpinfo(); data into the xdebug validation site and it said all was good. And you can see all the xdebug settings.
I have mapped port 9000 in the vagrant file.
config.vm.network :forwarded_port, guest: 9000, host: 9000
The vagrant box has host only network that exposes 192.168.10.100 as the IP of the server.
And I've tried all manner of different xdebug options, the ones on the ATOM plugin site suggest..
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
But that is a slightly confusing as remote_connect_back=1 means xdebug will ignore the remote_host setting - so not sure why both are in there - neither work.
I've restarted apache / php after each time I change the options, and check they are loaded with phpinfo();
If I check who is listening on port 9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Atom\x20H 10656 Matt 28u IPv6 0x321cb0a96ba5b593 0t0 TCP *:cslistener (LISTEN)
VBoxHeadl 10889 Matt 19u IPv4 0x321cb0a981a71433 0t0 TCP *:cslistener (LISTEN)
You can see both vagrant (virtual box) and Atom. Although Atom is IPv6 which is odd....
But enabling the debugger in ATOM, setting a breakpoint and hitting the site, nothing happens - ATOM never connects.
Any ideas? Anyone got this to work?
But that is a slightly confusing as remote_connect_back=1 means xdebug will ignore the remote_host setting
You are correct -- that option is not needed there -- it better be set to 0
xdebug.remote_host=127.0.0.1
This is wrong (unless you will be doing debugging via SSH tunnel). It must be an IP where debug client (Atom in your case) is running. It's xdebug who connects to client and NOT other way around: https://xdebug.org/docs/remote
This also means that the IP must be as seen from that Vagrant machine. Possibly the easiest way of getting it -- look at what $_SERVER['REMOTE_ADDR'] has.
I have mapped port 9000 in the vagrant file.
config.vm.network :forwarded_port, guest: 9000, host: 9000
You do not need to expose 9000 port in Vagrant -- nobody will be connecting to it (like you do with port 80 for web server) -- it's xdebug from VM/guest OS will be connecting outside to your "real"/host OS.
If anything -- you should be allowing outgoing connections on that port instead of incoming.
If I check who is listening on port 9000
This one means that Atom is unable to receive incoming xdebug connection over TCPv4 .. which xdebug will try to use by default (unless you specify IPv6 address in xdebug.remote_host).
If anything -- collect xdebug log (xdebug.remote_log) and see where it tries to connect etc.
#LazyOne already answered this question, but issue I had was caused by antivirus (MCAfee) which was blocking incoming traffic. Maybe this will help someone in the future.

Weblogic + Docker + Vagrant = Connection Issue

first time poster, but have been very impressed with this community. I've spent an embarrassing amount of time this week trying to resolve this issue - there doesn't seem to be much info on the net & I am stuck. Thanks in advance for any insights!
I am moving an existing WLS application into Docker. Goal is to have a repeatable Dev environment with WLS inside container & those containers running inside Vagrant (custom RHEL 6.5 VirtualBox).
I configured & started WLS container. I am also able to access WLS services from the container on VM. However, when I try to access the container from the host, I receive a connection timeout error.
I am running a private network 10.10.10.41 on Vagrant with port forwarding 7771:7001 - if I access that IP:Port (as I normally would when running a service within Vagrant), I get a connection refused.
I am able to run WLS "natively" from the VM and access from the host successfully. I am also able to run Apache conatiners from within the VM and access them from the host successfully. So the issue appears specific to WLS running inside a container in VM.
I turned off the firewall on the VM, which I've read is a common issue with Vagrant + Docker.
I have a whole host of information to share, but rather than drink from the firehose I will start out with a couple pieces. Happy to attach any further info as necessary. Thanks again!
Vagrantfile
config.vm.network "private_network", ip: "10.10.10.41"
config.vm.network :forwarded_port, host: 7771, guest: 7001
Dockerfile
EXPOSE 7001
Dockerrun
docker run -d -p 7001:7001 -v /my/release:/domain/release --name "wladmin" --link wlmanaged:wlmanaged my/wladmin
Container IP
docker inspect -f '{{ .NetworkSettings.IPAddress }}' wladmin
172.17.0.13
nmap VM (localhost)
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000044s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
nmap VM (Vagrant private network IP)
Nmap scan report for 10.10.10.41
Host is up (0.000053s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
nmap WLS Docker Container
Nmap scan report for my.domain.com (172.17.0.11)
Host is up (0.000055s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
7001/tcp open afs3-callback
7002/tcp open afs3-prserver
I found the root cause & wanted to share back.
It turns out that because Vagrant has a private network adapter, we have to bind the container to that adapter using.
docker run -d -p 10.10.10.41:7001:7001 -v /my/release:/domain/release --name "wladmin" --link wlmanaged:wlmanaged my/wladmin

Vagrant port forwarding not working on Mavericks

I'm using a vagrant Geodjango box and port forwarding is not working for me.
On the box, I have run:
python manage.py runserver 0.0.0.0:8000
But http://localhost:8000 and http://localhost:4567 both find nothing on the host machine.
On the Vagrant box, curl -v 'http://localhost:8000/' gives the usual:
<h2>Congratulations on your first Django-powered page.</h2>
which suggests that Django is running okay. But on the host machine, trying curl -v 'http://localhost:8000/' gives the following output:
curl: (7) Failed connect to localhost:8000; Connection refused
My Vagrantfile has the following port forwarding set up:
config.vm.forward_port 8000, 4567
Disabling the Mac's firewall does not help and stopping Apache makes no difference. I have tried running lsof -i :8000 on the host machine and there is no output, so I figure nothing is using the port.
Can anyone suggest anything?
I had the same issue on Yosemite and none of the ports were forwarding. Disabling the Firewall filter on the guest machine helped:
sudo service iptables stop
Good to see you figured it out yourself.
Just want to add my 2 cents, in V2 Vagrantfile, the port forwarding code block is like below, try to use the new ones so as to avoid port conflicts (back in v1 I always got confused which is which).
config.vm.forward_port 8000, 4567 is forwarding guest port 8000 to host 4567, not the other way around.
In V2 format, it looks like below, which is clearer from my opinion
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080
end

Resources