FG
📡 Networking

Version 0.5.0 returns "Invalid argument to getAgent" on examples

Freshalmost 15 years ago
Mar 14, 20260 views
Confidence Score86%
86%

Problem

I'm new to http-proxy but after running the example here: https://github.com/nodejitsu/node-http-proxy/blob/v0.5.0/examples/basic-proxy.js With some modifications (changed path of http-proxy to work in my environment) it starts but immediately throws an exception when the first client tries to connect. Is there additional setup I need to do to get it running? I am running node v0.5.0-pre according to "node --version" and just pulled http-agent from npm today (2011, April 26th). Here is the full exception: <pre>http.js:1446 throw new TypeError('Invalid argument to getAgent'); ^ TypeError: Invalid argument to getAgent at Object.getAgent (http.js:1446:11) at _getAgent (/home/tim/local/node/lib/node/.npm/http-proxy/0.5.0/package/lib/node-http-proxy.js:48:30) at [object Object].proxyRequest (/home/tim/local/node/lib/node/.npm/http-proxy/0.5.0/package/lib/node-http-proxy.js:377:12) at Server.<anonymous> (/home/tim/local/node/lib/node/.npm/http-proxy/0.5.0/package/lib/node-http-proxy.js:146:13) at Server.emit (events.js:67:17) at HTTPParser.onIncoming (http.js:1109:12) at HTTPParser.onHeadersComplete (http.js:108:31) at Socket.ondata (http.js:1008:22) at Socket._onReadable (net.js:682:27) at IOWatcher.onReadable [as callback] (net.js:177:10)</pre>

Error Output

exception when the first client tries to connect.  Is there additional setup I need to do to get it running?  I am running node v0.5.0-pre according to "node --version" and just pulled http-agent from npm today

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate1 verificationLast verified Mar 14, 2026

Solution: Version 0.5.0 returns "Invalid argument to getAgent" on examples

Low Risk

My testing shows this example does work in version 0.3.1 but not 0.4.1, 0.4.2, or 0.5.0.

84

Trust Score

1 verification

100% success
  1. 1

    My testing shows this example does work in version 0.3.1 but not 0.4.1, 0.4.2, o

    My testing shows this example does work in version 0.3.1 but not 0.4.1, 0.4.2, or 0.5.0.

Validation

Resolved in http-party/node-http-proxy GitHub issue #38. Community reactions: 0 upvotes.

Verification Summary

Worked: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

proxyhttpnode.js