• December 22, 2024

Run cURL commands from Windows console – Stack Overflow

how to run curl command in windows powershell,how to install curl on windows 10,curl windows 10,windows curl equivalent,download curl for windows,curl is not working in windows,curl tutorial,how to run curl command in postman

What is the cURL command in Windows?
cURL is a command line tool and a library which can be used to receive and send data between a client and a server or any two machines connected over the internet. It supports a wide range of protocols like HTTP, FTP, IMAP, LDAP, POP3, SMTP and many more.

cURL is a command line tool and a library which can be used to receive and send data between a client and a server or any two machines connected over the internet. It supports a wide range of protocols like HTTP, FTP, IMAP, LDAP, POP3, SMTP and many more.

How do I install cURL on Windows 10?
:@ syntax, as shown:
curl boolean:[email protected]/
In both of these methods, curl makes a “Basic” authentication with the server.
Testing protocol support with cURL
Due to the wide range of protocols supported by cURL, you can even use it to test protocol support. If you want to check if a site supports a certain version of SSL, you can use the –sslv or –tlsv flags. For example, if you want to check if a site supports TLS v1. 2, you can use:
curl -v –tlsv1. 2 The request takes place normally, which means that the site supports TLSv1. 2. Now, let us check if the site supports SSL v3:
curl -v –sslv3 This command throws a handshake_failed error, because the server doesn’t support this version of SSL.
Please note that, depending on your system and the library version/configuration, some of these version options may not work. The above output was taken from Ubuntu 16. 04’s cURL. However, if you try this with cURL in MacOS 10. 14, it gives an error:
You can also test for HTTP protocol versions in the same way, by using the flags –1. 0, –1. 1 or –2.
Setting the Host header and cURL’s –resolve option
Previously, we have discussed about how a web server chooses to serve different websites to visitors depending upon the “Host” header. This can be very useful to check if your website has virtual hosting configured correctly, by changing the “Host” header. As an example, say you have a local server at 192. 168. 0. 1 with two websites configured, namely and Now, you can test if everything is configured correctly by setting the Host header and checking if the correct contents are served:
curl -H ‘Host: ‘ curl -H ‘Host: ‘ Unfortunately, this doesn’t work so well for websites using HTTPS. A single website may be configured to serve multiple websites, with each website using its own SSL/TLS certificate. Since SSL/TLS takes place at a lower level than HTTP, this means clients such as cURL have to tell the server which website we’re trying to access at the SSL/TLS level, so that the server can pick the right certificate. By default, cURL always tells this to the server.
However, if you want to send a request to a specific IP like the above example, the server may pick a wrong certificate and that will cause the SSL/TLS verification to fail. The Host header only works at the HTTP level and not the SSL/TLS level.
To avoid the problem described above, you can use the –resolve flag. The resolve flag will send the request to the port and IP of your choice but will send the website name at both SSL/TLS and HTTP levels correctly.
Let us consider the previous example. If you were using HTTPS and wanted to send it to the local server 192. 1, you can use:
curl –resolve
It also works well for HTTP. Suppose, if your HTTP server was serving on port 8080, you can use either the –resolve flag or set the Host header and the port manually, like so:
curl -H ‘Host: ‘
The two commands mentioned above are equivalent.
Resolve domains to IPv4 and IPv6 addresses
Sometimes, you may want to check if a site is reachable over both IPv4 or IPv6. You can force cURL to connect to either the IPv4 or over IPv6 version of your site by using the -4 or -6 flags.
Please bear in mind that a website can be reached over IPv4 and IPv6 only if:
There are appropriate DNS records for the website that links it to IPv4 and IPv6 addresses.
You have IPv4 and IPv6 connectivity on your system.
For example, if you want to check if you can reach the website over IPv6, you can use:
curl -6 If the site is reachable over HTTPS, you should get your own IPv6 address in the output. This website returns the public IP address of any client that connects to it. So, depending on the protocol used, it displays an IPv4 or IPv6 address.
You can also use the -v option along with -4 and -6 to get more details.
Disabling cURL’s certificate checks
By default, cURL checks certificates when it connects over HTTPS. However, it is often useful to disable the certificate checking, when you are trying to make requests to sites using self-signed certificates, or if you need to test a site that has a misconfigured certificate.
To disable certificate checks, use the -k certificate. We will test this by making a request to, which is a website using an expired SSL certificate.
curl -k With the -k option, the certificate checks are ignored. So, cURL downloads the page and displays the request body successfully. On the other hand, if you didn’t use the -k option, you will get an error, similar to the one below:
Troubleshooting website issues with “cURL timing breakdown”
You may run into situations where a website is very slow for you, and you would like to dig deeper into the issue. You can make cURL display details of the request, such as the time taken for DNS resolution, establishing a connection etc. with the -w option. This is often called as a cURL “timing breakdown”.
As an example, if you want to see these details for connecting to, run:
curl -sSo /dev/null -w ‘namelookup:\t%{time_namelookup}\nconnect:\t%{time_connect}\nappconnect:\t%{time_appconnect}\npretransfer:\t%{time_pretransfer}\nredirect:\t%{time_redirect}\nstarttransfer:\t%{time_starttransfer}\ntotal:\t\t%{time_total}\n’
(If you are running this from a Windows system, change the /dev/null to NUL).
You will get some output similar to this:
Each of these values is in seconds, and here is what each value represents:
namelookup — The time required for DNS resolution.
connect — The time required to establish the TCP connection.
appconnect — This is the time taken to establish connections for any layers between TCP and the application layer, such as SSL/TLS. In our case, the application layer is HTTP. Also, if there is no such intermediate layer (such as when there is a direct HTTP request), this time will always be 0.
pretransfer — This is the time taken from the start to when the transfer of the file is just about to begin.
redirect — This is the total time taken to process any redirects.
starttransfer — Time it took from the start to when the first byte is about to be transferred.
total — The total time taken for cURL to complete the entire process.
As an example, say, you are facing delays connecting to a website and you notice the “namelookup” value was too high. As this indicates a problem with your ISP’s DNS server, you may start looking into why the DNS lookup is so slow, and switch to another DNS server if needed.
cURL configuration files
Sometimes, you may want to make all cURL requests use the same options. Passing these options by hand isn’t a feasible solution, so cURL allows you to specify options in a configuration file.
The default configuration file is located in ~/ in Linux/MacOS and%appdata%\_curlrc in Windows. Inside this file, you can specify any options that you need, such as:
# Always use IPv4
-4
# Always show verbose output
-v
# When following a redirect, automatically set the previous URL as referer.
referer = “;auto”
# Wait 60 seconds before timing out.
connect-timeout = 60
After creating the above file, try making a request with curl You will find that these options have taken effect.
If you want to use a custom configuration file instead of the default one, then you can use -K option to point curl to your configuration file. As an example, if you have a configuration file called, then you can use it with:
curl -K
Conclusion
In this article, we have covered the most common uses of the cURL command. Of course, this article only scratches the surface and cURL can do a whole lot of other things. You can type man curl in your terminal or just visit this page to see the man page which lists all the options.” alt=”” title=”” />

Frequently Asked Questions about curl “”{subdomain}. “” \ -G –data-urlencode “”query=type:ticket status:open”” \ -v -u {email_address}:{password}”

Leave a Reply