
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 http://127.0.0.1/tutorials/
The above example, will cURL to default port 80 and connect to the IP of localhost i.e. 127.0.0.1
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 http://192.168.1.125:8080/tutorials/
Example 4: IPv6 with port 8090
$ curl http://[::ffff:c0a8:7d]:8090/tutorials/
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!