cURL Example using IP (IPv4 and IPv6) address and Port

cURL with IP and Port Examples

In order to do a cURL on an IP address instead of a domain name or hostname, you can make use of the IP address instead.

curl http://xx.xx.xx.xx/sub-directory/

Example 1: IPv4 with default port 80:
$ curl

The above example, will cURL to default port 80 and connect to the IP of localhost i.e.

In order to cURL to an IPv6 address, you will need to provide the IPv6 address inside square brackets,

Example 2: IPv6 with default port 80:
$ curl http://[::1]/tutorials/

Again the above will connect to the localhost at port 80.

Let's see some examples with a non-custom port like 8080,

Example 3: IPv4 with port 8080
$ curl

Example 4: IPv6 with port 8090
$ curl http://[::ffff:c0a8:7d]:8090/tutorials/

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap