Binding a cURL request to one outbound interface keeps a single transfer on the network path you choose instead of whichever route the host picks by default. That matters on systems with multiple uplinks, VPN tunnels, lab interfaces, or several local addresses where the default route is not the one you want to test.
Use --interface when the request must leave through one device or one local source address. cURL accepts an interface name, a local IP address, or an explicit selector such as if!en0 for an interface name. The option binds the client socket only; it does not change how the URL hostname is resolved, and using a hostname as the interface value adds a separate local name lookup.
The examples below use the local loopback interface so the bind is easy to verify on one host. Replace lo0, 127.0.0.1, and the sample URL with the real interface name, source address, and target you need. On Windows, bind with a configured local IP address because cURL does not support interface names there.
$ ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
On Linux, ip -brief address show dev lo gives the same kind of quick readout. Use an interface or local address that already has a working route to the target.
$ curl --silent --show-error --interface if!lo0 http://127.0.0.1:8765/hello.txt network bind ok
The if! prefix tells cURL to treat the value strictly as an interface name. Replace lo0 with the interface you actually want, such as en0, eth0, or ens3.
$ curl --silent --show-error --verbose --interface if!lo0 http://127.0.0.1:8765/hello.txt * Trying 127.0.0.1:8765... * socket successfully bound to interface 'lo0' * Connected to 127.0.0.1 (127.0.0.1) port 8765 > GET /hello.txt HTTP/1.1 > Host: 127.0.0.1:8765 ##### snipped ##### < HTTP/1.0 200 OK ##### snipped ##### network bind ok
The decisive line is socket successfully bound to interface. If that line is missing, the request did not bind the way you expected.
$ curl --silent --show-error --interface 127.0.0.1 http://127.0.0.1:8765/hello.txt network bind ok
Address binding is the most portable form of --interface. On cURL 8.9.0 and later, ifhost!en0!192.0.2.24 can require both the interface and the source address in one value.
$ curl --silent --show-error --interface if!en999 http://127.0.0.1:8765/hello.txt curl: (45) Couldn't bind to interface 'en999'
Error 45 means cURL could not bind the socket to the requested interface or local address. If the hostname in the URL still resolves to the wrong backend, fix that separately with How to override DNS resolution with cURL.