Running Consul on Vagrant: Port forwarding from guest to host not working on Mac OS X
I would like to setup a Consul Cluster with a UI on my local machine (Mac OS X) using Vagrant.
So far I simply followed the Getting Started instructions of the official Consul Docs: https://www.consul.io/intro/getting-started/join.html
In order to be able to access the UI from the host, I simply added this one line to the provided Vagrantfile (https://github.com/hashicorp/consul/blob/master/demo/vagrant-cluster/Vagrantfile)
n1.vm.network "forwarded_port", guest: 8500, host: 8500
To start Consul with a UI on the guest machine I ssh into the machine and then simply added the -ui flag to the provided command:
consul agent -server -bootstrap-expect=1
-data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10
-enable-script-checks=true -config-dir=/etc/consul.d -ui
Consul starts without problems and from with the guest machine I can execute:
curl -v 'http://localhost:8500/ui/'
and the expected HTML page is returned.
Trying to access http://localhost:8500/ui/
in a browser or via curl on the host does not work though. Using curl on the host results in:
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8500 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8500 (#0)
> GET /ui/ HTTP/1.1
> Host: localhost:8500
> User-Agent: curl/7.54.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
Anything I am missing with setting up the port forwarding correctly?
The logs after running vagrant up
look good to me:
n1: Forwarding ports...
n1: 8500 (guest) => 8500 (host) (adapter 1)
macos vagrant portforwarding consul
add a comment |
I would like to setup a Consul Cluster with a UI on my local machine (Mac OS X) using Vagrant.
So far I simply followed the Getting Started instructions of the official Consul Docs: https://www.consul.io/intro/getting-started/join.html
In order to be able to access the UI from the host, I simply added this one line to the provided Vagrantfile (https://github.com/hashicorp/consul/blob/master/demo/vagrant-cluster/Vagrantfile)
n1.vm.network "forwarded_port", guest: 8500, host: 8500
To start Consul with a UI on the guest machine I ssh into the machine and then simply added the -ui flag to the provided command:
consul agent -server -bootstrap-expect=1
-data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10
-enable-script-checks=true -config-dir=/etc/consul.d -ui
Consul starts without problems and from with the guest machine I can execute:
curl -v 'http://localhost:8500/ui/'
and the expected HTML page is returned.
Trying to access http://localhost:8500/ui/
in a browser or via curl on the host does not work though. Using curl on the host results in:
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8500 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8500 (#0)
> GET /ui/ HTTP/1.1
> Host: localhost:8500
> User-Agent: curl/7.54.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
Anything I am missing with setting up the port forwarding correctly?
The logs after running vagrant up
look good to me:
n1: Forwarding ports...
n1: 8500 (guest) => 8500 (host) (adapter 1)
macos vagrant portforwarding consul
add a comment |
I would like to setup a Consul Cluster with a UI on my local machine (Mac OS X) using Vagrant.
So far I simply followed the Getting Started instructions of the official Consul Docs: https://www.consul.io/intro/getting-started/join.html
In order to be able to access the UI from the host, I simply added this one line to the provided Vagrantfile (https://github.com/hashicorp/consul/blob/master/demo/vagrant-cluster/Vagrantfile)
n1.vm.network "forwarded_port", guest: 8500, host: 8500
To start Consul with a UI on the guest machine I ssh into the machine and then simply added the -ui flag to the provided command:
consul agent -server -bootstrap-expect=1
-data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10
-enable-script-checks=true -config-dir=/etc/consul.d -ui
Consul starts without problems and from with the guest machine I can execute:
curl -v 'http://localhost:8500/ui/'
and the expected HTML page is returned.
Trying to access http://localhost:8500/ui/
in a browser or via curl on the host does not work though. Using curl on the host results in:
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8500 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8500 (#0)
> GET /ui/ HTTP/1.1
> Host: localhost:8500
> User-Agent: curl/7.54.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
Anything I am missing with setting up the port forwarding correctly?
The logs after running vagrant up
look good to me:
n1: Forwarding ports...
n1: 8500 (guest) => 8500 (host) (adapter 1)
macos vagrant portforwarding consul
I would like to setup a Consul Cluster with a UI on my local machine (Mac OS X) using Vagrant.
So far I simply followed the Getting Started instructions of the official Consul Docs: https://www.consul.io/intro/getting-started/join.html
In order to be able to access the UI from the host, I simply added this one line to the provided Vagrantfile (https://github.com/hashicorp/consul/blob/master/demo/vagrant-cluster/Vagrantfile)
n1.vm.network "forwarded_port", guest: 8500, host: 8500
To start Consul with a UI on the guest machine I ssh into the machine and then simply added the -ui flag to the provided command:
consul agent -server -bootstrap-expect=1
-data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10
-enable-script-checks=true -config-dir=/etc/consul.d -ui
Consul starts without problems and from with the guest machine I can execute:
curl -v 'http://localhost:8500/ui/'
and the expected HTML page is returned.
Trying to access http://localhost:8500/ui/
in a browser or via curl on the host does not work though. Using curl on the host results in:
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8500 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8500 (#0)
> GET /ui/ HTTP/1.1
> Host: localhost:8500
> User-Agent: curl/7.54.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
Anything I am missing with setting up the port forwarding correctly?
The logs after running vagrant up
look good to me:
n1: Forwarding ports...
n1: 8500 (guest) => 8500 (host) (adapter 1)
macos vagrant portforwarding consul
macos vagrant portforwarding consul
asked Oct 6 '17 at 16:06
user2350644user2350644
902915
902915
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You have 2 options :
- Use a static IP (either a public network or private network) so you will bind your consul agent on the static IP (say
172.20.20.10
) and you will be able to access throughhttp://172.20.20.10:8500/ui/
from your web browser
Note : in such case, you dont need to have the forwarded port in your Vagrantfile
- per consul doc on bind option
The address that should be bound to for internal cluster communications. This is an IP address that should be reachable by all other nodes in the cluster. By default, this is
"0.0.0.0"
, meaning Consul will bind to all addresses on the local machine
so you will be able to reach consul running on your VM from your host
NB: my preferences goes for option #1
1
thanks, you are right. I've already specified an IP in the private network, so there is no need for port forwarding. What I was missing was also specifying the client IP address to bind to. (consul.io/docs/agent/options.html#_client). So finally with this command the UI is available from the host onhttp://172.20.20.10:8500/ui/
. The command therefore needs to look as follows:consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
– user2350644
Oct 6 '17 at 21:14
add a comment |
consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
is a good solution, but it has side effect that any consul cli operations will return error because it uses 127.0.0.1
in http request. so maybe changing -client=172.20.20.10
to -client=0.0.0.0
is better.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46609794%2frunning-consul-on-vagrant-port-forwarding-from-guest-to-host-not-working-on-mac%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have 2 options :
- Use a static IP (either a public network or private network) so you will bind your consul agent on the static IP (say
172.20.20.10
) and you will be able to access throughhttp://172.20.20.10:8500/ui/
from your web browser
Note : in such case, you dont need to have the forwarded port in your Vagrantfile
- per consul doc on bind option
The address that should be bound to for internal cluster communications. This is an IP address that should be reachable by all other nodes in the cluster. By default, this is
"0.0.0.0"
, meaning Consul will bind to all addresses on the local machine
so you will be able to reach consul running on your VM from your host
NB: my preferences goes for option #1
1
thanks, you are right. I've already specified an IP in the private network, so there is no need for port forwarding. What I was missing was also specifying the client IP address to bind to. (consul.io/docs/agent/options.html#_client). So finally with this command the UI is available from the host onhttp://172.20.20.10:8500/ui/
. The command therefore needs to look as follows:consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
– user2350644
Oct 6 '17 at 21:14
add a comment |
You have 2 options :
- Use a static IP (either a public network or private network) so you will bind your consul agent on the static IP (say
172.20.20.10
) and you will be able to access throughhttp://172.20.20.10:8500/ui/
from your web browser
Note : in such case, you dont need to have the forwarded port in your Vagrantfile
- per consul doc on bind option
The address that should be bound to for internal cluster communications. This is an IP address that should be reachable by all other nodes in the cluster. By default, this is
"0.0.0.0"
, meaning Consul will bind to all addresses on the local machine
so you will be able to reach consul running on your VM from your host
NB: my preferences goes for option #1
1
thanks, you are right. I've already specified an IP in the private network, so there is no need for port forwarding. What I was missing was also specifying the client IP address to bind to. (consul.io/docs/agent/options.html#_client). So finally with this command the UI is available from the host onhttp://172.20.20.10:8500/ui/
. The command therefore needs to look as follows:consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
– user2350644
Oct 6 '17 at 21:14
add a comment |
You have 2 options :
- Use a static IP (either a public network or private network) so you will bind your consul agent on the static IP (say
172.20.20.10
) and you will be able to access throughhttp://172.20.20.10:8500/ui/
from your web browser
Note : in such case, you dont need to have the forwarded port in your Vagrantfile
- per consul doc on bind option
The address that should be bound to for internal cluster communications. This is an IP address that should be reachable by all other nodes in the cluster. By default, this is
"0.0.0.0"
, meaning Consul will bind to all addresses on the local machine
so you will be able to reach consul running on your VM from your host
NB: my preferences goes for option #1
You have 2 options :
- Use a static IP (either a public network or private network) so you will bind your consul agent on the static IP (say
172.20.20.10
) and you will be able to access throughhttp://172.20.20.10:8500/ui/
from your web browser
Note : in such case, you dont need to have the forwarded port in your Vagrantfile
- per consul doc on bind option
The address that should be bound to for internal cluster communications. This is an IP address that should be reachable by all other nodes in the cluster. By default, this is
"0.0.0.0"
, meaning Consul will bind to all addresses on the local machine
so you will be able to reach consul running on your VM from your host
NB: my preferences goes for option #1
answered Oct 6 '17 at 19:18
Frédéric HenriFrédéric Henri
34.5k55785
34.5k55785
1
thanks, you are right. I've already specified an IP in the private network, so there is no need for port forwarding. What I was missing was also specifying the client IP address to bind to. (consul.io/docs/agent/options.html#_client). So finally with this command the UI is available from the host onhttp://172.20.20.10:8500/ui/
. The command therefore needs to look as follows:consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
– user2350644
Oct 6 '17 at 21:14
add a comment |
1
thanks, you are right. I've already specified an IP in the private network, so there is no need for port forwarding. What I was missing was also specifying the client IP address to bind to. (consul.io/docs/agent/options.html#_client). So finally with this command the UI is available from the host onhttp://172.20.20.10:8500/ui/
. The command therefore needs to look as follows:consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
– user2350644
Oct 6 '17 at 21:14
1
1
thanks, you are right. I've already specified an IP in the private network, so there is no need for port forwarding. What I was missing was also specifying the client IP address to bind to. (consul.io/docs/agent/options.html#_client). So finally with this command the UI is available from the host on
http://172.20.20.10:8500/ui/
. The command therefore needs to look as follows: consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
– user2350644
Oct 6 '17 at 21:14
thanks, you are right. I've already specified an IP in the private network, so there is no need for port forwarding. What I was missing was also specifying the client IP address to bind to. (consul.io/docs/agent/options.html#_client). So finally with this command the UI is available from the host on
http://172.20.20.10:8500/ui/
. The command therefore needs to look as follows: consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
– user2350644
Oct 6 '17 at 21:14
add a comment |
consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
is a good solution, but it has side effect that any consul cli operations will return error because it uses 127.0.0.1
in http request. so maybe changing -client=172.20.20.10
to -client=0.0.0.0
is better.
add a comment |
consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
is a good solution, but it has side effect that any consul cli operations will return error because it uses 127.0.0.1
in http request. so maybe changing -client=172.20.20.10
to -client=0.0.0.0
is better.
add a comment |
consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
is a good solution, but it has side effect that any consul cli operations will return error because it uses 127.0.0.1
in http request. so maybe changing -client=172.20.20.10
to -client=0.0.0.0
is better.
consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -client=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d -ui
is a good solution, but it has side effect that any consul cli operations will return error because it uses 127.0.0.1
in http request. so maybe changing -client=172.20.20.10
to -client=0.0.0.0
is better.
answered Nov 25 '18 at 12:27
SimbaSimba
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46609794%2frunning-consul-on-vagrant-port-forwarding-from-guest-to-host-not-working-on-mac%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown