Starting nomad agent

I am running nomad on ec2 instance with ubuntu image. Whenever I give host address other than localhost it throws the error
Error querying node status: Get http://xx.xxx.xxx.xx:4646/v1/nodes: dial tcp xx.xxx.xxx.xx:4646: connect: connection refused
Here is my server.hcl
log_level = “DEBUG”

Setup data dir

data_dir = “/etc/nomad”
bind_addr = “xx.xxx.xxx.xx”

advertise {

Defaults to the first private IP address.

http = “xx.xxx.xxx.xx”
rpc = “xx.xxx.xxx.xx”
serf = “xx.xxx.xxx.xx”:4648" # non-default ports may be specified
}

Enable the server

server {
enabled = true

# Self-elect, should be 3 or 5 for production
bootstrap_expect = 1

}

I have also used export NOMAD_ADDR but its still not working

Hi @shoryavj if you’re running on EC2, there’s a couple things you’ll need to be sure of:

  • Make sure the bind_addr is set to the correct interface. You may want to use a sockaddr expression like "{{ GetInterfaceIP \"eth0\" }}. (The interface may be something like ens5 on a machine with systemd.)
  • Make sure that the NOMAD_ADDR is pointing to the public IP of the host (or the private IP if you’re connecting to your environment via a VPN).
  • Make sure the security group for your EC2 instance permits port 4646/tcp from your location (or the VPN endpoint, if you’re using a VPN).

It shows the same error when I run nomad in vagrant. NOMAD_ADDR is pointing to public IP only. I have also set the bind_addr correctly.

Error starting agent: server setup failed: Failed to start RPC layer: listen tcp 192.168.100.12:4647: bind: can't assign requested address
failed to initialize TLS listener: error="listen tcp 192.168.100.12:4647: bind: can't assign requested address"

Also where to add the sockaddr expression "{{ GetInterfaceIP \"eth0\" }} .
I am not running consul. Will it be a problem ??

May I suggest you look at this sample config to see what is missing/different.
(You will need to fill in the @@ bits)

Also you can find other useful tidbits in the same repo.

HTH
Shantanu Gadgil

I just used the wrong bind address.
Where have you defined your environment variables?