Socket error: "49: Can't assign requested address"

862 views
Skip to first unread message

Thijs Schreijer

unread,
Aug 26, 2016, 6:24:02 PM8/26/16
to openresty-en
Hello,

Having some trouble due to an error I'm getting.

This function connects a socket to a host that is first resolved to an ip address (custom dns resolver);

local connect = function(sock, host, port, opts)
 
local target_ip, target_port = dns_client.toip(host, port)
 
if not target_ip then return nil, target_port end
 
return sock:connect(target_ip, target_port, opts)

end



It is called as;
  local sock = ngx_socket_tcp()
  sock
:settimeout(conf.timeout)
  ok
, error = connect(sock, host, port)


The error I'm getting;
2016/08/26 23:36:40 [crit] 39494#0: *26 connect() to xx.xxx.xx.xxx:0 failed (49: Can't assign requested address), client: 127.0.0.1, server: kong, request: "GET /request HTTP/1.1", host: "ldap.com"

The IP address and port are properly resolved.

Have been googling around, but haven't been able to find an answer.

Any help solving this is appreciated.
Thx
Thijs

BTW; on osx if that matters...

Thijs Schreijer

unread,
Sep 15, 2016, 4:01:34 AM9/15/16
to openresty-en
Just for reference, this is the (by now resolved) issue; https://github.com/openresty/lua-nginx-module/issues/860

Op zaterdag 27 augustus 2016 00:24:02 UTC+2 schreef Thijs Schreijer:
Reply all
Reply to author
Forward
0 new messages