10% off ALL new Proxies – CODE: 10pro

Node.js Proxy Setup: axios & Puppeteer Mobile Proxy

Node.js Proxy Setup: axios & Puppeteer Mobile Proxy

Direct Answer

To use a mobile proxy in Node.js, route your client through your proxy endpoint. With axios, attach an https-proxy-agent (or socks-proxy-agent for SOCKS5). With Puppeteer, pass --proxy-server at launch and authenticate with page.authenticate(). Both send traffic through a real German mobile IP — add your endpoint, username and password from your account.


Before You Start

You will need four values from your GermanProxy.io account:

  • Host and port of your endpoint
  • Username and password

The examples use PROXY_HOST, PORT, USER and PASS as placeholders — replace them with your own. GermanProxy.io supports HTTP, SOCKS5 and OpenVPN, so pick whichever your tool prefers.


Using a Mobile Proxy with axios (HTTP)

axios does not handle HTTPS-over-proxy reliably through its built-in proxy option, so use an agent. Install it first:

npm install axios https-proxy-agent

Then pass the agent to your request:

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

const agent = new HttpsProxyAgent(`http://USER:PASS@PROXY_HOST:PORT`);

axios.get("https://www.example.de", {
  httpAgent: agent,
  httpsAgent: agent,
  proxy: false, // let the agent handle it; ignore HTTP(S)_PROXY env vars
  timeout: 30000,
})
  .then((res) => console.log(res.status, res.data.slice(0, 200)))
  .catch((err) => console.error(err.message));

Confirm the IP your target sees by requesting an IP-echo endpoint through the same agent before you build the rest of your pipeline.


Using a Mobile Proxy with axios (SOCKS5)

axios has no native SOCKS support, so use socks-proxy-agent:

npm install socks-proxy-agent
const axios = require("axios");
const { SocksProxyAgent } = require("socks-proxy-agent");

const agent = new SocksProxyAgent(`socks5://USER:PASS@PROXY_HOST:PORT`);

axios.get("https://www.example.de", {
  httpAgent: agent,
  httpsAgent: agent,
  proxy: false, // let the agent handle it; ignore HTTP(S)_PROXY env vars
  timeout: 30000,
}).then((res) => console.log(res.status));

Use socks5h:// instead of socks5:// if you want DNS resolution to happen at the proxy rather than locally.


Using a Mobile Proxy with Puppeteer

Puppeteer sets the proxy at the browser level via the --proxy-server launch flag, then authenticates per page:

const puppeteer = require("puppeteer");

(async () => {
  const browser = await puppeteer.launch({
    args: [`--proxy-server=PROXY_HOST:PORT`],
    headless: true, // new headless is the default since Puppeteer v22
  });
  const page = await browser.newPage();
  await page.authenticate({ username: "USER", password: "PASS" });

  await page.goto("https://www.example.de", { waitUntil: "domcontentloaded" });
  console.log(await page.title());
  await browser.close();
})();

Every page in that browser instance uses the same proxy. For a deeper walkthrough of launch args, stealth and IP verification, see the dedicated Puppeteer mobile proxy guide. For device-level consistency — so browser features like WebRTC also use the mobile endpoint — consider routing the whole machine over OpenVPN instead; see what a WebRTC leak is.


Sticky Sessions vs. Rotation

  • Sticky session: hold the same German mobile IP for the length of a task — ideal for multi-step flows that should look like one continuous user.
  • Rotation on demand: request a fresh IP when you want one — useful for spreading independent requests.

Choose per workflow rather than rotating blindly. For the concepts, see sticky sessions and IP rotation explained.


Scrape Responsibly

A mobile proxy improves reliability for legitimate data collection — it is not a tool to circumvent access controls or platform rules. Keep your pipeline clean and defensible:

  1. Respect robots.txt and each site's terms of service.
  2. Send requests at a human-reasonable rate — add delays and avoid hammering servers.
  3. Collect only what you need, and handle any personal data in line with the GDPR.
  4. Set an honest User-Agent that identifies your client, not a misleading one.

These habits keep both your data and your IP reputation healthy.


FAQ

Does this work with node-fetch, got or Playwright too?

Yes. Any client that accepts a proxy agent or proxy URL works the same way — node-fetch and got via an agent, Playwright via its proxy launch option. The endpoint and credentials are identical. For Playwright specifically, see the Python guide, whose proxy object maps directly to the Node API.

Why do I get a 407 error?

A 407 Proxy Authentication Required means your credentials are missing or wrong. Check username, password, host and port — and see how to fix 407 proxy authentication required.

HTTP or SOCKS5 — which should I use?

HTTP is simplest for web requests; SOCKS5 is more flexible and lets the proxy handle DNS (socks5h). For most Node scraping, either works — see SOCKS5 vs HTTP proxy.


CTA

Build your Node.js pipeline on real German mobile IPs. Get a German mobile proxy — HTTP/SOCKS5/OpenVPN, sticky sessions, fair-use 20 GB/day.


Get a German mobile proxy: Real 4G/5G IPs from Germany, fair-use 20 GB/day — see German 4G/5G mobile proxy options or try a shared 5G German proxy.

Telegram Support
Nach oben scrollen