Agent keep trying to connect at 127.0.0.1

Hi All,

i’m struglling to get my agent working correctly.

When i ran a job it keeps to give the local address with this error


root@nomad-test:~/nomad_jobs# nomad plan test_jobs_qemu.hcl 
Error during plan: Put "http://127.0.0.1:4646/v1/job/apt-cache-server/plan": dial tcp 127.0.0.1:4646: connect: connection refused

In my agent config i set up bond_addr and advertise:

agent server:

bind_addr = "172.18.212.232"

advertise {
  # Defaults to the first private IP address.
  http = "172.18.212.232"
  rpc  = "172.18.212.232"
  serf = "172.18.212.232:4648" # non-default ports may be specified
}

and i got this error from journalctl:


Oct 30 11:12:50 nomad-test nomad[8435]:     2023-10-30T11:12:50.746+0100 [ERROR] nomad: memberlist: Failed to read remote state: msgpack decode error [pos 1]: only encoded map or array can be decoded into a struct from=172.18.212.233:50938

here my agent client confguration:

datacenter = "test"
data_dir  = "/var/lib/nomad"
bind_addr = "172.18.212.233"

advertise {
  # Defaults to the first private IP address.
  http = "172.18.212.233"
  rpc  = "172.18.212.233"
  serf = "172.18.212.233:4648" # non-default ports may be specified
}

client {
  enabled = true
  servers = ["172.18.212.232"]
  network_interface = "ens18"
  server_join {
    retry_join = ["172.18.212.232:4648"]
  }
}

From webui everything is okay, i just can’t run any jobs…

Do yo have any idea if there is a misconfiguration ?

Hi @NutZ57,

The API client the CLI uses will default to connecting to 127.0.0.1:4646 when executed, which will need to be altered is your Nomad agent API is not running and bound to that address. If you run nomad plan -h you will see the available flags, which include the -address flag. Your command execution would therefore look something like nomad plan -address="http://172.18.212.232:4646" test_jobs_qemu.hcl

Thanks,
jrasell and the Nomad team

yep thats’ work.
Thanks a lot for the detailed answer !

1 Like