{"id":20710170,"url":"https://github.com/oxylabs/curl-with-proxy","last_synced_at":"2025-04-23T04:51:57.883Z","repository":{"id":134336583,"uuid":"469644626","full_name":"oxylabs/curl-with-proxy","owner":"oxylabs","description":"A tutorial on using cURL command with proxies","archived":false,"fork":false,"pushed_at":"2025-02-11T12:47:54.000Z","size":22,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T22:21:07.772Z","etag":null,"topics":["curl","curl-library","curl-proxy","curl-with-proxy","github-proxy-list","proxy","proxy-list","proxy-site","rotating-proxy","shell","socks5-proxy","socks5-proxy-list","socks5-server","web-proxy","web-proxy-server","webproxy"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-03-14T08:34:21.000Z","updated_at":"2025-02-11T20:36:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"78c3a7a3-e59c-4ae9-8227-b5799742d4ac","html_url":"https://github.com/oxylabs/curl-with-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-with-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-with-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-with-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-with-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxylabs","download_url":"https://codeload.github.com/oxylabs/curl-with-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372947,"owners_count":21419722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","curl-library","curl-proxy","curl-with-proxy","github-proxy-list","proxy","proxy-list","proxy-site","rotating-proxy","shell","socks5-proxy","socks5-proxy-list","socks5-server","web-proxy","web-proxy-server","webproxy"],"created_at":"2024-11-17T02:10:19.134Z","updated_at":"2025-04-23T04:51:57.875Z","avatar_url":"https://github.com/oxylabs.png","language":"Shell","readme":"# How to Use cURL With Proxy\n\n[![Oxylabs promo code](https://raw.githubusercontent.com/oxylabs/product-integrations/refs/heads/master/Affiliate-Universal-1090x275.png)](https://oxylabs.go2cloud.org/aff_c?offer_id=7\u0026aff_id=877\u0026url_id=112)\n\n[![](https://dcbadge.vercel.app/api/server/eWsVUJrnG5)](https://discord.gg/GbxmdGhZjq)\n\n[\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Curl\u0026color=brightgreen\" /\u003e](https://github.com/topics/curl) [\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Proxy\u0026color=important\" /\u003e](https://github.com/topics/proxy)\n\n- [What is cURL?](#what-is-curl)\n- [Installation](#installation)\n- [What you need to connect to a proxy](#what-you-need-to-connect-to-a-proxy)\n- [Command line argument to set proxy in cURL](#command-line-argument-to-set-proxy-in-curl)\n- [Using environment variables](#using-environment-variables)\n- [Configure cURL to always use proxy](#configure-curl-to-always-use-proxy)\n- [Ignore or override proxy for one request](#ignore-or-override-proxy-for-one-request)\n- [Bonus tip – turning proxies off and on quickly](#bonus-tip--turning-proxies-off-and-on-quickly)\n- [cURL socks proxy](#curl-socks-proxy)\n\nThis step-by-step guide will explain how to use cURL or, simply, curl with proxy servers. It covers all the aspects, beginning from installation to explaining various options to set the proxy.\n\nFor a detailed explanation, see our [blog post](https://oxy.yt/ArRn).\n\n## What is cURL?\n\ncURL is a command line tool for sending and receiving data using the URL. The following command gets the HTML of the page and prints it in the console:\n\n```shell\ncurl https://www.google.com\n```\n\n## Installation\n\ncURL is provided with many Linux distributions and MacOS. Now, it is also provided with Windows 10. You can check whether your computer has curl installed by opening your terminal and running the following command:\n\n```shell\ncurl --version\n```\n\n## What you need to connect to a proxy\n\nYou’ll need the following information to anonymize curl behind a proxy:\n\n- proxy server address\n- port\n- protocol\n- username (if authentication is required)\n- password (if authentication is required)\n\nIn this tutorial, let's assume that the proxy server is **127.0.0.1**, the port is **1234**, the user name is **user**, and the password is **pwd**. We will look into multiple examples covering various protocols.\n\n## Command line argument to set proxy in cURL\n\nOpen the terminal, type the following command, and press Enter:\n\n```shell\ncurl --help\n```\n\nThe output is going to be a huge list of options. One of them is going to look like this:\n\n```shell\n-x, --proxy [protocol://]host[:port] \n```\n\nNote that **x** is lowercase, and it is case-sensitive. The proxy details can be supplied using the **-x** or **–proxy** switch. Both mean the same thing:\n\n```shell\ncurl -x \"http://user:pwd@127.0.0.1:1234\" \"http://httpbin.org/ip\"\n```\n\nor\n\n```shell\ncurl --proxy \"http://user:pwd@127.0.0.1:1234\" \"http://httpbin.org/ip\"\n```\n\n**NOTE.** If there are SSL certificate errors, add **-k** (lowercase) to the **curl** command. This will allow insecure server connections when using SSL:\n\n```shell\ncurl --proxy \"http://user:pwd@127.0.0.1:1234\" \"http://httpbin.org/ip\" -k\n```\n\nAnother interesting thing to note here is that the default proxy protocol is HTTP. Thus, the following two commands will do exactly the same:\n\n```shell\ncurl --proxy \"http://user:pwd@127.0.0.1:1234\" \"http://httpbin.org/ip\"\ncurl --proxy \"user:pwd@127.0.0.1:1234\" \"http://httpbin.org/ip\"\n```\n\n## Using environment variables\n\nAnother way to use proxy with curl is to set the environment variables **http_proxy** and **https_proxy**:\n\n```shell\nexport http_proxy=\"http://user:pwd@127.0.0.1:1234\"\nexport https_proxy=\"http://user:pwd@127.0.0.1:1234\"\n```\n\nAfter running these two commands, run **curl** normally:\n\n```shell\ncurl \"http://httpbin.org/ip\"\n```\n\nTo stop using a proxy, turn off the global proxy by unsetting these two variables:\n\n```shell\nunset http_proxy\nunset https_proxy\n```\n\n## Configure cURL to always use a proxy\n\nIf you want a proxy for curl but not for other programs, you can create a [curl config file](https://everything.curl.dev/cmdline/configfile.html).\n\nFor Linux and MacOS, open the terminal and navigate to your home directory. If there is already a **.curlrc** file, open it. If there is none, create a new file. Here are the set of commands that can be run:\n\n```shell\ncd ~\nnano .curlrc\n```\n\nIn this file, add a proxy authorization line:\n\n```shell\nproxy=\"http://user:pwd@127.0.0.1:1234\"\n```\n\nSave the file. Now, curl with proxy is ready to be used. \n\nSimply run **curl** normally and it will read the proxy from **.curlrc** file.\n\n```shell\ncurl \"http://httpbin.org/ip\"\n```\n\nOn Windows, the file is named **_curlrc**. This file can be placed in the **%APPDATA%** directory.\n\nTo find the exact path of **%APPDATA%**, open the command prompt and run the following command:\n\n```shell\necho %APPDATA%\n```\n\nThis directory will be something like **C:\\Users\\\u003cyour_user\u003e\\AppData\\Roaming**. Now go to this directory, create a new file **_curlrc**, and set the proxy by adding this line:\n\n```shell\nproxy=\"http://user:pwd@127.0.0.1:1234\"\n```\n\nIt works exactly the same way in Linux, MacOS, and Windows.\n\n## Ignore or override proxy for one request\n\nTo override the proxy for one request, set the new proxy using the **-x** or **–proxy** switch as usual:\n\n```shell\ncurl --proxy \"http://user:pwd@1.0.0.1:8090\" \"http://httpbin.org/ip\"\n```\n\n## Bonus tip – turning proxies off and on quickly\n\nYou can create an alias in your **.bashrc** file to set proxies and unset proxies. For example, open the **.bashrc** file using any editor and add these lines:\n\n```shell\nalias proxyon=\"export http_proxy=' http://user:pwd@127.0.0.1:1234';export https_proxy=' http://user:pwd@127.0.0.1:1234'\"\nalias proxyoff=\"unset http_proxy;unset https_proxy\"\n```\n\nAfter adding the lines, save the **.bashrc** and update the shell to read this **.bashrc**. To do this, run this command in the terminal:\n\n```shell\n. ~/.bashrc\n```\n\nNow, you can quickly turn on the proxy, run one or more curl commands, and then turn off the proxies like this:\n\n```shell\nproxyon\ncurl \"http://httpbin.org/ip\"\ncurl \"http://google.com\"\nproxyoff \n```\n\n## cURL SOCKS proxy\n\nIf the proxy server is using the SOCKS protocol, the syntax remains the same:\n\n```shell\ncurl -x \"socks5://user:pwd@127.0.0.1:1234\" \"http://httpbin.org/ip\"\n```\n\nIf you want to learn more about using cURL with proxy, see our [blog post](https://oxy.yt/ArRn).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fcurl-with-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxylabs%2Fcurl-with-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fcurl-with-proxy/lists"}