---
title: "Use cURL's \"--resolve\" option to pin a request to an IP address"
date: "2022-02-11T05:16:11+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/92831-use-curls-resolve-option-pin-request-ip-address"
id: "c8b36fff-0a10-4ee5-9403-1e7b26d65511"
---

When preparing to launch a website, or debugging problems with a site that's already live, sometimes it can be helpful to bypass CDN and proxy layers when requesting content from the site by sending those web requests directly to a specific IP address without using the site's public DNS records. This practice of "pinning" a web request directly to a server can be accomplished by [changing your /etc/hosts file](/node/92616) , which will cause requests for a specified domain name (e.g: "[www.example.com](http://www.example.com/)") to be routed from your local machine to a specified IP address (e.g: 127.0.0.1) until the changes you've made to /etc/hosts are reverted.

However, what if you want to pin a _single request_ to an IP address, without modifying your system's configuration files? Happily, this sort of "ad-hoc" request-pinning is possible via command-line with [cURL](https://en.wikipedia.org/wiki/CURL), which provides a special **`resolve`** option, formatted `--resolve [DOMAIN]:[PORT]:[IP]`, that routes all web requests performed during the execution of a cURL command that match a given \[`DOMAIN]` and \[`PORT]` to a specified \[`IP]` address. The values specified by this option (which can be invoked multiple times in a single command to route multiple domain/port combinations to various IP addresses) will apply to the initial request, and also to any redirects that cURL follows during the course of the command.

**Examples:**

The following curl command:

    curl http://www.example.com --resolve www.example.com:80:127.0.0.1

...will force cURL to use "127.0.0.1" as the IP address when requesting "[www.example.com](http://www.example.com/)" over port 80 (HTTP).

The command above can be augmented to look like this:

    curl http://www.example.com --resolve www.example.com:80:127.0.0.1 --resolve www.example.com:443:127.0.0.1

...which will force cURL to use  "127.0.0.1" as the IP address for requests to "[www.example.com](http://www.example.com/)" over ports 80 (HTTP _and_ 443 (HTTPS). This can be useful for sites that automatically redirect HTTP requests to HTTPS requests as a security measure.

Remember, `--resolve` can be specified multiple times (and for multiple domain/port combinations) for a single cURL command, allowing you to establish complex routing rules for requests that you know will be redirected multiple times across various domains and ports.