This is a glossary of all the common issues in Request - Tunnel Agent
  • 01-Jan-2023
Lightrun Team
Author Lightrun Team
This is a glossary of all the common issues in Request - Tunnel Agent

Troubleshooting Common Issues in Request – Tunnel Agent

Lightrun Team
Lightrun Team

Project Description


The tunnel-agent module is a utility that is used to create HTTP and HTTPS tunneling agents for the Request library. It allows you to create an HTTP or HTTPS agent that can be used to tunnel HTTP or HTTPS requests through a proxy server.

Here is an example of how you can use the tunnel-agent module to create an HTTPS tunneling agent that connects to a proxy server at http://localhost:8080:

const tunnel = require('tunnel-agent');

const agent = tunnel.httpsOverHttp({
  proxy: {
    host: 'localhost',
    port: 8080

// Use the agent when making HTTPS requests with the Request library
  url: '',
  agent: agent
}, function (error, response, body) {
  console.log('error:', error);
  console.log('statusCode:', response && response.statusCode);
  console.log('body:', body);

In this example, the httpsOverHttp function creates an HTTPS agent that connects to the specified proxy server and then tunnels HTTPS requests through the proxy. The agent is then passed to the request function as the agent option, which causes the request to be tunneled through the proxy.


Troubleshooting Request – Tunnel Agent with the Lightrun Developer Observability Platform


Getting a sense of what’s actually happening inside a live application is a frustrating experience, one that relies mostly on querying and observing whatever logs were written during development.
Lightrun is a Developer Observability Platform, allowing developers to add telemetry to live applications in real-time, on-demand, and right from the IDE.
  • Instantly add logs to, set metrics in, and take snapshots of live applications
  • Insights delivered straight to your IDE or CLI
  • Works where you do: dev, QA, staging, CI/CD, and production

The most common issues for Request – Tunnel Agent are:


Tunneling socket could not be established


The “tunneling socket could not be established” error is usually encountered when there is a problem connecting to the proxy server when using the tunnel-agent module with the Request library. This can occur for a variety of reasons, such as an incorrect proxy URL or a network issue that is preventing the connection to the proxy server.

To troubleshoot this error, you can try the following steps:

  1. Make sure that the proxy URL and port are correct.
  2. Check your network connection to ensure that there are no issues that are preventing the connection to the proxy server.
  3. If you are using a self-signed certificate for the proxy server, you may need to disable certificate verification by setting the rejectUnauthorized option to false.
  4. If the issue persists, you may want to try using a different proxy server to see if the problem is specific to the proxy that you are using.


More issues from Request repos


Troubleshooting request-request 


It’s Really not that Complicated.

You can actually understand what’s going on inside your live applications.

Try Lightrun’s Playground

Lets Talk!

Looking for more information about Lightrun and debugging?
We’d love to hear from you!
Drop us a line and we’ll get back to you shortly.

By submitting this form, I agree to Lightrun’s Privacy Policy and Terms of Use.