> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Residential Proxies with Node.js (Axios)

> Step-by-step guide to using ZenRows Residential Proxies with Node.js and Axios, including setup, configuration, and troubleshooting.

In this guide, we'll walk you through using ZenRows® Residential Proxies with Node.js and Axios. You'll learn how to integrate the proxies into your requests and troubleshoot common issues. We'll also address some frequently asked questions about residential proxies.

## Installing Axios

First, make sure you have Node.js installed. Then, navigate to your project directory and install Axios using `npm` by running:

```bash theme={null}
npm install axios
```

This will install Axios, a popular promise-based `HTTP` client for Node.js, and add it to your project.

## Making Requests with ZenRows Residential Proxies

Follow the steps below to use ZenRows Residential Proxies with Node.js `axios` library.

<Steps>
  <Step title="Get Your Credentials">
    Navigate to the ZenRows Residential Proxy [Generator Page](https://app.zenrows.com/proxies/generator) to get your username, password, and proxy domain.
  </Step>

  <Step title="Configure the Proxy URL">
    If necessary, configure your proxy URL on the Generator Page following the guide on [Residential Proxies Setup](/residential-proxies/residential-proxies-setup). Your proxy URL should be in this format:

    ```bash theme={null}
    http://<YOUR_USERNAME>:<YOUR_PASSWORD>@superproxy.zenrows.com:1337
    ```

    Replace `<YOUR_USERNAME>` and `<YOUR_PASSWORD>` with your ZenRows proxy credentials.
  </Step>

  <Step title="Code Example">
    Here's an example of sending a request through ZenRows Residential Proxies to `httpbin.io/ip`, which returns the IP address used for the request.

    ```javascript scraper.js theme={null}
    const axios = require('axios');

    // Proxy credentials
    const proxy = {
        protocol: 'http'
        host: 'superproxy.zenrows.com',
        port: '1337',
        auth: {
            username: '<YOUR_USERNAME>',
            password: '<YOUR_PASSWORD>'
        }
    };

    // Target URL (httpbin returns your IP address)
    const targetURL = 'https://httpbin.io/ip';

    // Make request using Axios and Residential Proxy
    axios({
        method: 'get',
        url: targetURL,
        proxy: proxy
    })
    .then(response => {
        console.log('Your IP Address:', response.data);
    })
    .catch(error => {
        console.error('Error:', error.message);
    });
    ```

    Expected output:

    ```javascript theme={null}
    Your IP Address: { origin: 'your-residential-proxy-ip' }
    ```
  </Step>
</Steps>

## Troubleshooting

Here are some common issues you may encounter when using ZenRows Residential Proxies with Node.js `axios`.

### Invalid Proxy Credentials

If you encounter a `407 Proxy Authentication Required` or a `401 Unauthorized` error, double-check your `username` and `password` in the auth section of your proxy configuration. Ensure that they match the credentials in the [ZenRows dashboard](https://app.zenrows.com/proxies/generator).

### Axios Version

You're likely to encounter errors if your Axios version is outdated. Ensure you're using a recent version of Axios that supports your proxy configuration. Older versions may have bugs or lack features for specific proxy setups. To ensure you install the latest version, run the following installation command:

```bash theme={null}
npm install axios@latest
```

### Connection Refused or Blocked

If your requests are being blocked or refused, ensure:

* You are correctly matching the protocol (http or https) and port (1337 or 1338).
* The website you're targeting is not actively blocking you. Some websites employ advanced anti-bot measures that detect proxies.

### Invalid Proxy URL Format

Ensure the proxy URL format is correct. It should follow the structure:

```bash theme={null}
http://username:password@proxy-host:port
```

If any component is missing or incorrectly formatted, the request will fail.

### IP Rotation Settings

If you're not seeing your IP change as expected, check your Sticky TTL settings on ZenRows. If the Sticky TTL is too long, the same IP will be used for multiple requests. Reduce the Sticky TTL to rotate IPs more frequently.

## Frequently Asked Questions (FAQs)

<Accordion title="Can I use HTTPS with ZenRows® Residential Proxies?">
  Yes, ZenRows Residential Proxies support both HTTP and HTTPS. In Axios, you just need to specify the appropriate protocol in the `proxy.host` value or use an HTTPS URL.
</Accordion>

<Accordion title="How can I change the IP rotation interval?">
  ZenRows automatically rotates IPs for each request unless you configure a Sticky TTL to keep the same IP for a specific period. This helps in scenarios where maintaining the same IP for a session is required.
</Accordion>

<Accordion title="What should I do if my requests are blocked?">
  Many websites employ advanced anti-bot measures, such as CAPTCHAs and Web Application Firewalls (WAFs), to prevent automated scraping. Simply using proxies may not be enough to bypass these protections.

  Instead of relying solely on proxies, consider using [ZenRows' Universal Scraper API](https://app.zenrows.com/builder), which provides:

  * **JavaScript Rendering and Interaction Simulation:** Optimized with anti-bot bypass capabilities.
  * **Comprehensive Anti-Bot Toolkit:** ZenRows offers advanced tools to overcome complex anti-scraping solutions.
</Accordion>

<Accordion title="What is the Sticky TTL?">
  The Sticky TTL (Time To Live) feature allows you to maintain the same IP address for a specified duration, from 30 seconds up to 24 hours. If you don't set a Sticky TTL, ZenRows will rotate the IP with every request.
</Accordion>

<Accordion title="How do I know if my proxy is working?">
  You can test if the proxy is working by sending a request to `https://httpbin.io/ip`. The proxy is successfully applied if the response shows an IP address different from your local IP.
</Accordion>

For further assistance, feel free to <a href="mailto:success@zenrows.com">contact us</a>. 😉
