Axios

This article explains how to use MaskProxy with Axios requests. Axios can be used with proxies and is suitable for interface access, testing and compliance data requests in Node.js projects.

Step 1: Prepare proxy parameters in the MaskProxy dashboard

  1. Log in to the MaskProxy dashboard.
  2. Enter "My Proxy" and open the product you want to use: rotating residential proxy, rotating datacenter proxy, static residential proxy or static datacenter proxy.
  3. Copy proxy host, port, username and password.
  4. Select HTTP or SOCKS5 protocol based on tool support.
  5. Dynamic proxy first confirms the remaining GB traffic; static proxy first confirms that the IP status is normal and has not expired.

Axios usually requires these four parameters: host, port, username, and password. If the tool only accepts one line of proxy, the following general format can be used.

username:password@host:port

Step 2: Install proxy

npm install axios https-proxy-agent socks-proxy-agent

HTTP protocol example

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

const proxyUrl = 'http://username:password@host:port';
const agent = new HttpsProxyAgent(proxyUrl);

axios.get('https://api.ipify.org?format=json', {
  httpAgent: agent,
  httpsAgent: agent,
  proxy: false
}).then(res => console.log(res.data));

SOCKS5 protocol example

const axios = require('axios');
const { SocksProxyAgent } = require('socks-proxy-agent');

const proxyUrl = 'socks5://username:password@host:port';
const agent = new SocksProxyAgent(proxyUrl);

axios.get('https://api.ipify.org?format=json', {
  httpAgent: agent,
  httpsAgent: agent,
  proxy: false
}).then(res => console.log(res.data));

Step 3: Test connection

  1. Click "Test proxy" "Check proxy" in Axios or save and open the IP query page.
  2. Confirm that the exit IP is different from the real IP of the machine.
  3. Confirm that the export region is generally consistent with the background selection.
  4. If it is a dynamic proxy, observe whether the IP switching meets the current time limit when making multiple requests; if it is a static proxy, confirm that the exit IP remains stable.

Common troubleshooting

  • Connection failure: Check whether the host and port are complete, and only fill in numbers for the port.
  • Authentication failed: Copy the username and password again, avoiding extra spaces or line breaks.
  • Protocol Error: Confirm that the HTTP or SOCKS5 protocol was selected in the tool and not another protocol type.
  • Region inconsistency: Use multiple IP query sites for cross-validation.
  • The dynamic proxy cannot be used: check the remaining GB traffic; the static proxy cannot be used: check the IP status and expiration time.

Please only use proxy in compliance business scenarios, and comply with the usage rules of the target website, platform and third-party tools. Do not send the complete proxy string, password or API link to public channels.

Powered by MaskProxy