Using Residential Proxies with Node.js (Axios)
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:
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.
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:
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.
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:
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:
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)
For further assistance, feel free to contact us. 😉
Was this page helpful?