How to Set Up Proxies with Node-Fetch (Configuration Tutorial)

In this comprehensive guide, we'll cover integrating proxies with Node-Fetch specifically on Windows, MacOS, and Linux platforms. I'll provide OS-specific examples, troubleshooting tips, and usage best practices on each platform.

Why Use Proxies with Node-Fetch?

Node-Fetch brings the browser Fetch API to Node.js, making it easy to make HTTP requests. However, websites often block IP addresses that make too many requests.

This is where proxies come in handy! Using proxies rotates your IP address with each request, preventing blocks. Proxies also let you bypass geographic restrictions and access content only available in certain regions.

So integrating proxies with Node-Fetch is crucial for successful web scraping and data collection projects.

Best Proxy Providers Recommend

There are many proxy providers out there:

  • Bright Data – Largest proxy network with 72+ million IPs
  • Smartproxy – Enterprise proxy pool ideal for large scrapers
  • Proxy-Seller – Budget residential proxies with wide coverage
  • Soax – Residential proxies great for general scraping

Obtain the credentials for your chosen provider. Typically this includes a username, password, proxy hostname, and port.


First, ensure you have Node.js installed:

  • Windows – Download and run the .msi installer from
  • MacOS – Use Homebrew: brew install node
  • Linux – Use package manager like apt, yum or compile from source

Then install the required packages globally:


npm install -g node-fetch@2
npm install -g https-proxy-agent


sudo npm install -g node-fetch@2 
sudo npm install -g https-proxy-agent

Construct the Proxy URL

Embed your proxy credentials in the URL:


$proxyUrl = 'http://user:[email protected]:8080'


proxyUrl='http://user:[email protected]:8080'

Make sure to use your own credentials and proxy server details.

Create the Proxy Agent


const HttpsProxyAgent = require('https-proxy-agent');

const agent = new HttpsProxyAgent($proxyUrl);


const HttpsProxyAgent = require('https-proxy-agent');

const agent = new HttpsProxyAgent(proxyUrl);

Make Proxied Requests


const fetch = require('node-fetch');

fetch('', { agent })
  .then(res => console.log(res));


const fetch = require('node-fetch');

fetch('', { agent })
  .then(res => console.log(res));

This shows the core proxy integration logic on each OS.

Now let's discuss some tips…

Windows-Specific Tips

  • Consider using Proxifier for system-wide proxy support
  • Make sure Windows Firewall isn't blocking connections
  • Handle authentication failures caused by AMSI
  • Use PowerShell for managing environment variables
  • Spawn Node-Fetch processes using .NET APIs

MacOS-Specific Tips

  • Use launchctl to set proxy environment variables
  • Brew install libs like OpenSSL if certificate issues
  • Avoid deprecated macOS Node.js versions lacking ES6
  • Implement a Launch Agent for production scraping

Linux-Specific Tips

  • Set proxy env vars like HTTPS_PROXY in bash
  • Use proxychains for system-wide proxying
  • Check SELinux is not blocking connections
  • Make sure Node.js runtime matches distro version
  • Use cluster module for load balancing requests
  • systemd service scripts for production scraping


In summary, this guide detailed integrating proxies with Node-Fetch. By installing Node-Fetch and Https-Proxy-Agent, obtaining proxy credentials, and setting up the ProxyAgent, you're equipped to effectively scrape at scale. Follow these steps for optimal results.

John Rooney

John Rooney

John Watson Rooney, a self-taught Python developer and content creator with a focus on web scraping, APIs, and automation. I love sharing my knowledge and expertise through my YouTube channel, My channel caters to all levels of developers, from beginners looking to get started in web scraping to experienced programmers seeking to advance their skills with modern techniques. I have worked in the e-commerce sector for many years, gaining extensive real-world experience in data handling, API integrations, and project management. I am passionate about teaching others and simplifying complex concepts to make them more accessible to a wider audience. In addition to my YouTube channel, I also maintain a personal website where I share my coding projects and other related content.

We will be happy to hear your thoughts

      Leave a reply

      Compare items
      • Total (0)