# Unable to bind\_to\_device

**URL:** <https://erlangforums.com/t/unable-to-bind-to-device/2080>\
**Category:** Questions / Help\
**Tags:** socket\
**Created:** [November 25, 2022, 6:01pm UTC](https://erlangforums.com/t/unable-to-bind-to-device/2080 "2022-11-25T18:01:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rychale](https://erlangforums.com/user_avatar/erlangforums.com/rychale/32/1745_2.png) [@rychale](https://erlangforums.com/u/rychale)\
**Post date:** [November 25, 2022, 6:01pm UTC](https://erlangforums.com/t/unable-to-bind-to-device/2080/1 "2022-11-25T18:01:16Z")

</div>

Hello,

Trying to set SO\_BINDTODEVICE flag on a socket like:

```erlang
iex(8)> :gen_tcp.connect({8, 8, 8, 8}, 53, [inet_backend: :socket, bind_to_device: 'ens3', active: false])
** (exit) :badarg
    (kernel 8.5.1) gen_tcp_socket.erl:137: :gen_tcp_socket.connect_lookup/4
    (kernel 8.5.1) gen_tcp_socket.erl:103: :gen_tcp_socket.connect/4

```

If I understand correctly this is not capabilities related issue, I’m just passing the arguments in a wrong way or so.

Can anyone help, please?

---

<div class="post-metadata">

**Author:** ![Fantarina](https://erlangforums.com/user_avatar/erlangforums.com/fantarina/32/1511_2.png) [@Fantarina](https://erlangforums.com/u/Fantarina)\
**Post date:** [November 28, 2022, 6:55am UTC](https://erlangforums.com/t/unable-to-bind-to-device/2080/2 "2022-11-28T06:55:25Z")

</div>

Hi, as per the doc {bind\_to\_device, Ifname :: binary()} so Ifname should be a binary and you should be passing the arguments in tuples like this:

```erlang
gen_tcp:connect({8, 8, 8, 8}, 53, [{inet_backend,socket}, {bind_to_device, <<"ens2">>}, {active,false}]).

```

I don’t know if this will work tho
