How to Use cURL with Proxy

A drawing of a laptop connected to an HTTP and SOCKS server next to the title

Share

IN THIS ARTICLE:

As a developer, you do a lot of debugging, testing of geo-restricted content, and routing traffic through a proxy server for privacy or compliance. Using cURL can make it much easier to work from behind a proxy.

With just a few flags, you can tell cURL to send traffic through HTTP or SOCKS proxies with or without authentication. Since cURL supports everything from simple IP:port pairs to full proxy credentials, it’s a great option for developers.

In this guide, we’ll walk through the different ways to use cURL with proxy servers, including:

  • How to use HTTP and SOCKS5 proxies
  • How to pass authentication credentials
  • How to verify that your requests are actually being routed through the proxy

Using cURL you can use both HTTP and SOCKS proxies with just a few flags.

A drawing of a server and a shield showing HTTP and a terminal icon under the title

How to Use an HTTP Proxy with cURL

cURL HTTP Proxy without Authentication

Using an HTTP proxy with cURL is straightforward. You just need to pass the proxy address using the -x or --proxy flag.

Basic Syntax:

curl -x http://proxyhost:port https://example.com

Example:

curl -x http://192.168.1.100:8080 https://httpbin.org/ip

In the example above:

  • -x tells cURL to use a proxy
  • http://192.168.1.100:8080 is the proxy server
  • The request to https://httpbin.org/ip will go through the proxy

CURL HTTP Proxy with Authentication

If your proxy requires a username and password, include them in the proxy URL:

curl -x http://username:password@proxyhost:port https://example.com

Example:

curl -x http://user123:[email protected]:8080 https://httpbin.org/ip

When to use:

  • Your network requires traffic to go through an internal proxy
  • You want to test how your API behaves from a different location/IP
  • You’re debugging traffic that passes through CDN or proxy layers

Security tip: Avoid pasting proxy credentials directly into the command line. You can use --proxy-user instead:

curl --proxy http://proxyhost:port --proxy-user user:pass https://example.com

A drawing of a laptop connecting through a sock to a server under the title

How to Use a SOCKS Proxy with cURL?

SOCKS proxies operate at a lower level than HTTP proxies, making them perfect for routing any kind of traffic, not just HTTP. This is especially handy when testing applications, accessing geo-restricted content, or tunneling traffic securely through another server.

cURL SOCKS Proxy without Authentication

You can use --socks5, --socks4, or socks5-hostname depending on the version of SOCKS and DNS resolution behavior.

curl --socks5 socks_host:port https://example.com

Example:

curl --socks5 127.0.0.1:9050 https://httpbin.org/ip

This tells cURL to route traffic through the SOCKS5 proxy running locally on port 9050 (which is the default port for Tor).

cURL SOCKS Proxy with Authentication

If the SOCKS proxy requires a username and a password:

curl --socks5-user user --socks5-password pass --socks5 socks_host:port https://example.com

Example:

curl --socks5-user myuser --socks5-password mypass --socks5 192.168.0.5:1080 https://httpbin.org/ip

a blue and purple neon diagram under the title

SOCKS vs HTTP Proxy with cURL

FeatureHTTP ProxySOCKS Proxy
Protocol-specificYes (HTTP/S only)No (can proxy any protocol)
DNS resolution controlLimitedMore flexible (hostname vs IP)
Use casesAPIs, web requestsFull tunneling, Tor, dev/test
Supported in cURLYesYes (with --socks5, etc.)
Source: Proxidize

--socks5-hostname vs --socks5

  • –socks5: DNS resolution happens on the client side.
  • –socks5-hostname: DNS resolution happens on the proxy side.

Use --socks5-hostname when:

  • You want to hide DNS queries from your ISP.
  • You’re using a remote proxy (e.g., Tor node, VPN, or remote gateway).
curl --socks5-hostname 127.0.0.1:9050 https://example.com

A drawing of a laptop and server connected to a shield icon under the title

How to Use an HTTPS Proxy with cURL

While HTTP proxies are more common, HTTPS proxies offer an added layer of security by encrypting the traffic between your machine and the proxy server. This is useful when working in environments where privacy and confidentiality are critical such as corporate networks, VPN-like setups, or secure data pipelines.

cURL HTTPS Proxy without Authentication

Basic Syntax for HTTPS Proxy:

To use an HTTPS proxy with cURL, you can use the --proxy flag and specify the scheme as https://

curl --proxy https://proxy_host:proxy_port https://example.com

Example:

curl --proxy https://myproxy.example.com:443 https://httpbin.org/ip

This commands routes your requests to httpbin.org through an HTTPS proxy

Using HTTPS Proxy with Authentication

If your HTTPS proxy requires a username and password, you can include them inline or use --proxy-user.

Inline in the URL (basic auth):

curl --proxy https://username:password@proxy_host:port https://example.com

Or with --proxy-user:

curl --proxy https://proxy_host:port --proxy-user username:password https://example.com

Example:

curl --proxy https://proxy.mycompany.com:443 --proxy-user admin:secure123 https://example.com

Avoid hardcoding credentials in scripts; use environments, variables, or prompt users securely.

Handling HTTPS Proxy with Self-Signed Certificates

If your HTTPS proxy uses a self-signed certificate (common in internal networks), you may run into certificate errors. You can skip SSL verification only if you trust the proxy:

curl --proxy https://proxy.example.com:443 --proxy-insecure https://example.com

Alternatively, you can add a custom CA bundle with:

curl --proxy-cacert my-ca.crt --proxy https://proxy.example.com:443 https://example.com

Verbose Output (Optional for Debugging)

Want to see how the connection flows through the proxy?

curl -v --proxy https://proxy.example.com:443 https://example.com

This will show you the full TLS handshake, proxy connection status, and headers exchanged.

Summary Table

FeatureUsage Example
HTTPS Proxy (no auth)curl --proxy https://host:port https://site.com
HTTPS Proxy (with auth)--proxy-user user:pass or inline URL
Self-signed cert bypass--proxy-insecure
Provide custom CA for proxy--proxy-cacert file.crt
Debug with verbose-v

How to Use cURL with Proxy Authentication

Many proxy servers require authentication for access, especially in corporate networks or paid proxy services. Fortunately, cURL makes it easy to handle proxy auth.

Basic Proxy Authentication with --proxy-user:

The most common way is to use the --proxy-user option:

curl --proxy http://proxy.example.com:8080 --proxy-user username:password https://example.com

This will include a Proxy-Authorization header with your request.

Example:

curl --proxy http://123.45.67.89:8080 --proxy-user myuser:mypass https://httpbin.org/ip

You’ll get a response from httpbin.org, routed through the proxy with credentials included 

Supported Authentication Methods:

By default, cURL tries Basic authentication, but if the proxy requires NTLM, Digest, or Negotiate/Kerberos, cURL supports those too:

  • Use --proxy-ntlm for NTLM
  • Use --proxy-digest for Digest auth
  • Use --proxy-negotiate for Kerberos or Negotiate

Example:

curl --proxy http://proxy.company.local:8080 --proxy-user domain\\user:pass --proxy-ntlm https://example.com

Keep in mind that double backslashes \\ are required in Windows domain-style logins.

Conclusion

Now that we’ve covered a variety of ways to use cURL with proxy servers, we hope you can see how useful this setup is in different scenarios. Using proxy with cURL can make a developer’s life much easier, especially when working with APIs, managing large scale requests, or testing behavior across multiple regions.

Key takeaways:

  • Use --proxy to specify a proxy server.
  • Use --proxy-user to authenticate with username and password.
  • Use --proxy-ntlm, --proxy-digest, or --proxy-negotiate for advanced authentication methods.
  • Use HTTPS proxies for secure communication.
  • Combine with flags like -x, -v, or -L for full control.

Setting the right authentication method is super important, choosing the right proxy protocol, and combining flags like -L (follow redirects) or -v (verbose output) can make your proxy setup smoother and more powerful.

About the author

Yazan is a Software Engineer at Proxidize with a passion for technology and a love for building things with code. He has worked in several industries, including consulting and healthcare, and is currently focused on proxy technologies.
IN THIS ARTICLE:

Save Up To 90% on Your Proxies

Discover the world’s first distributed proxy network, which guarantees the best IP quality, reliability and price.

Related articles

How Does Image Scraping Work?

People share over 3.2 billion images online every day. Downloading these images manually is a grueling and time-consuming task, especially

Zeid Abughazaleh

What is Scrapoxy? All Your Proxies on One Interface

Scrapoxy is an open source proxy orchestration tool that unifies multiple proxies behind one user-friendly endpoint. It started as a

Omar Rifai

Using cURL with Python

If you have experience with Python or have been reading documentation related to the programming language, you may have come

Zeid Abughazaleh

Choosing Between Puppeteer vs Selenium

Choosing between Puppeteer vs Selenium should be a straightforward concept but there are various things to keep in mind before

Zeid Abughazaleh

Start for Free! Start for Free! Start for Free! Start for Free! Start for Free! 

Talk to Our Sales Team​

Looking to get started with Proxidize? Our team is here to help.

“Proxidize has been instrumental in helping our business grow faster than ever over the last 12 months. In short, Proxidize has empowered us to have control over every part of our business, which should be the goal of any successful company.”

mobile-1.jpg
Makai Macdonald
Social Media Lead Specialist | Product London Design UK

What to Expect:

By submitting this form, you consent to receive marketing communications from Proxidize regarding our products, services, and events. Your information will be processed in accordance with our Privacy Policy. You may unsubscribe at any time.

Contact us
Contact Sales