Unable to invoke a remote URL via lua script

Hi,
I hope this is something simple.
I’m trying to play with a lua script that makes a remote HTTP/ REST call . I plan to eventually perform some more complex logic on the returned result but for now, I’d just like to see it work.

I’m not sure why it doesn’t work (no relevant info in the haproxy log)

If I comment out the relevant lines (commented out in the snippet below) and just return “web1”, the script works, so it’s definately getting called

Thanks

    core.register_fetches("select_backend_2", function(txn)
    --  local httpclient = core.httpclient()
    --  local api_base_url = "https://example.com/api/endpoint" 
    --  local request_body = "" 
    --  local response = httpclient:get{url = api_base_url, body=request_body}
      return "web1"
    end)

Invocation

    frontend myfrontend
      bind :8080
      # Simple function
      use_backend %[lua.select_backend_2]   

LUA in HAProxy context can’t resolve DNS. You can try using IP address of your remote host and it will work. I was the same issue and fixed that way.