     [Answers](https://scrapfly.io/blog)   /  [http](https://scrapfly.io/blog/tag/http)   /  [How to use proxies with NodeJS axios?](https://scrapfly.io/blog/answers/how-to-use-proxies-nodejs-axios)   # How to use proxies with NodeJS axios?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) May 16, 2023 1 min read [\#http](https://scrapfly.io/blog/tag/http) [\#nodejs](https://scrapfly.io/blog/tag/nodejs) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-use-proxies-nodejs-axios "Share on LinkedIn")    

 

 

Javascript's [axios](https://docs.guzzlephp.org/en/stable/) is a popular HTTP client often used when web scraping with nodejs. To use proxies with axios we can use the `proxy` parameter in `get` and `post`j methods:

javascript```javascript
const axios = require('axios');
axios.get('https://httpbin.dev/ip', {
  proxy: {
    host: "160.11.12.13",
    port: "8080",
    auth: {
      username: "username",
      password: "password",
    }
  }
})
.then((response) => {
  console.log(response.data);
})
.catch((error) => {
  console.error(error);
});
```



Note that `axios` does not support automatic proxy use through terminal environment variables `HTTP_PROXY`, `HTTPS_PROXY` or `ALL_PROXY`.

Axios also does not support SOCKS proxies directly but it can be enabled through [socks-proxy-agent](https://www.npmjs.com/package/socks-proxy-agent/) library:

javascript```javascript
const axios = require('axios');
const SocksProxyAgent = require('socks-proxy-agent');

const proxy = 'socks5://localhost:1080';

const httpAgent = new SocksProxyAgent(proxy);
const httpsAgent = new SocksProxyAgent(proxy);

axios.get('http://example.com', {
  httpAgent,
  httpsAgent,
})
.then((response) => {
  console.log(response.data);
})
.catch((error) => {
  console.error(error);
});
```



Finally, when web scraping, it's best to rotate proxies for each request. For that see our article: [How to Rotate Proxies in Web Scraping](https://scrapfly.io/blog/posts/how-to-rotate-proxies-in-web-scraping)



 

   Table of Contents















 

   Join the Newsletter  Get monthly web scraping insights 

 

  



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

## Explore this Article with AI

 [ ChatGPT ](https://chat.openai.com/?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-use-proxies-nodejs-axios) [ Gemini ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-use-proxies-nodejs-axios) [ Grok ](https://x.com/i/grok?text=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-use-proxies-nodejs-axios) [ Perplexity ](https://www.perplexity.ai/search/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-use-proxies-nodejs-axios) [ Claude ](https://claude.ai/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-use-proxies-nodejs-axios) 



 ## Related Articles

 [  

 http nodejs 

### How to Set Axios Headers: Complete Guide with Examples (2026)

Learn how to set, manage, and troubleshoot Axios headers: per-request config, global defaults, instances, interceptors, ...

 

 ](https://scrapfly.io/blog/posts/guide-to-javascript-axios-headers) [  

 http nodejs 

### Web Scraping With NodeJS and Javascript

In this article we'll take a look at scraping using Javascript through NodeJS. We'll cover common web scraping libraries...

 

 ](https://scrapfly.io/blog/posts/web-scraping-with-nodejs) [  

 http nodejs 

### Axios vs Fetch: Which HTTP Client to Choose in JS?

Explore the differences between Fetch and Axios - two essential HTTP clients in JavaScript - and discover which is best ...

 

 ](https://scrapfly.io/blog/posts/axios-vs-fetch) 

  ## Related Questions

- [ Q How to use proxies with Python httpx? ](https://scrapfly.io/blog/answers/how-to-use-proxies-python-httpx)
- [ Q How To Send cURL POST Requests? ](https://scrapfly.io/blog/answers/how-to-send-a-post-request-using-curl)
- [ Q How to use proxies with PHP Guzzle? ](https://scrapfly.io/blog/answers/how-to-use-proxies-php-guzzle)
- [ Q How to find HTML elements by text with Cheerio and NodeJS? ](https://scrapfly.io/blog/answers/how-to-find-html-elements-by-text-with-cheerio)
 
  



   



 Scale your web scraping effortlessly, **1,000 free credits** [Start Free](https://scrapfly.io/register)