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.
First, make sure you have Node.js installed. Then, navigate to your project directory and install Axios using npm
by running:
This will install Axios, a popular promise-based HTTP
client for Node.js, and add it to your project.
Follow the steps below to use ZenRows Residential Proxies with Node.js axios
library.
Get Your Credentials
Navigate to the ZenRows Residential Proxy Generator Page to get your username, password, and proxy domain.
Configure the Proxy URL
If necessary, configure your proxy URL on the Generator Page following the guide on Residential Proxies Setup. Your proxy URL should be in this format:
Replace <YOUR_USERNAME>
and <YOUR_PASSWORD>
with your ZenRows proxy credentials.
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.
Expected output:
Here are some common issues you may encounter when using ZenRows Residential Proxies with Node.js axios
.
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.
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:
If your requests are being blocked or refused, ensure:
Ensure the proxy URL format is correct. It should follow the structure:
If any component is missing or incorrectly formatted, the request will fail.
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.
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.
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.
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, which provides:
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.
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.
For further assistance, feel free to contact us. 😉