CAPABILITY GENERATOR

LambdaTest DocumentationReal Time Testing ● Troubleshooting Lambda Tunnel

Troubleshooting Lambda Tunnel


Lambda Tunnel helps in establishing an SSH connection between your local machine and our cloud servers to help you perform tests on locally hosted websites and web-apps. With Lambda Tunnel, you can ensure how robust your website rendering is across 2000+ real browsers, even before you make it live on the internet.
If due to some unfortunate reason, you are unable to perform cross browser testing using Lambda Tunnel then this document will help you troubleshoot the most common challenges.


Oops !! Facing issue while testing your locally hosted application through Lambda tunnel? Here are a few guidelines for you.

1. Blocked PORT 22:


The most common reason why users are not able to configure the tunnel is because of blocked PORT 22 on their network. Since the standard TCP port for SSH is 22, it is mandatory to keep PORT 22 unblocked in order to connect your local system with LambdaTest servers via SSH based integration tunnel.
If your PORT 22 is blocked, you would get the logs on the terminal/cmd similar to the logs showed in below screenshot:
Blocked PORT 22

OR

Port22Blocked

So, the question that arises here is, how you can check if your network PORT 22 is actually blocked?
Here is the single common OS command for you to check:
telnet ltuns.lambdatest.com 22
For more further details regarding this, you can direct to the link.

2. Localhost refused to connect:


After configuring the tunnel, you might get into the error similar to the below screenshot:

Localhost refused to connect

The error “localhost refused to connect” occurs because of using the URL as localhost which is unfortunately not compatible with various browsers and browser versions. We are deliberately eliminating the URL localhost and recovering it with localhost.lambdatest.com or your local system IP.
For example you might find above error with URL:https://localhost/demo.html
however, URL:https://localhost.lambdatest.com/demo.html or 10.0.0.15/demo.html would definitely work fine for you.

3. Invalid Host Header:


While testing an application hosted on your local machine, you may receive an “Invalid Host Header” error message when testing on LambdaTest using a local connection. This error is most commonly caused by a misconfiguration of the application server that causes it to reject non-local connections or reject requests directed at hostnames other than localhost(or any custom one set)

Since, web applications are now built with various different kinds of frameworks like angular, react etc; In order to test it using tunnel the command used to run your web app needs to modified in your project manifest file i.e. “package.json”

Invalid Host Header:

  • Angular Framework Project: For Angular framework based web app, ideally you might be using “ng serve” or “npm start” to run your web application or your package.json file configuration would be set as “ng serve” in order to start your web app and as usual, it would be working fine on local browser. However, this might throw an “Invalid Host Header”error or error something related to the invalid host in a Real Time Test.

    To resolve this, here is the quick small solution for you. While running your application, you can either use command ng serve --host 0.0.0.0 --disable-host-check or set your start configuration in package.json file as “ng serve --host 0.0.0.0 --disable-host-check” instead of changing your running command.

  • React Framework Project: For React framework based web app, you need to create an env file in which you have to add the hostname,syntax: HOST=< hostname >, once you are done with it, now you can add your localhost IP along with your hostname in your system hosts file.
    Example: 127.0.0.1 < hostname >
    This would help you avoiding “Invalid Host Header” error.

4. WordPress- CSS not loading:


While testing your local web app built through WordPress, you may find issue with the rendering of CSS, similar to the below screenshot:

Wordpress- CSS not loading

The general solution for this is to update the WordPress Address and Site Address on the General Settings tab in the WordPress dashboard with your system IP address rather than the default of localhost, then everything will be emitted relative to that. Here is a screenshot for your further reference:

By applying the above changes, you would find the CSS loading issue as resolved. Below is a screenshot after the mentioned changed:

5. IP Whitelisting:


If you are testing a server that requires IP whitelisting, then you just have to set up a Local Testing connection and whitelist the below few IP’s :

  • 52.206.217.211
  • 13.232.45.218
  • 18.184.191.217

However be advised, as we are aggressively adding more and more data centers, these IP would changed, you can see the updated IP’s on this documentation as well.

6. No available PORT found:


Lambda tunnel binary is developed in a way that when starting, it tries to free port starting from 9090 till 9094 sequentially and if it doesn’t seem to find any free PORTS, then it would throw an error “No available Port found for 5 attempts”.

The reason behind this error is either your system has 5 active tunnels running simultaneously or the PORTS that tunnel is trying to find is already in use by another running application.

 No available PORT found

In such a scenario, it is suggested to append “-tunnelProxyPort ” along with the usual tunnel command in order to provide a desired free PORT number.

Example:
LT -user < username > -key < accessKey > -tunnelProxyPort < portNo >

7. Custom Host name:


Because of some firewall restrictions, your web application might not be accessible on some other servers even after whitelisting the IP’s and configuring the tunnel, in such case you need to make an entry in the hosts file which is used to map hostnames to IP addresses. With the hosts file, you can change the IP address that you resolve a given domain name. This change only affects your own computer without affecting how the domain is resolved worldwide.

This is particularly useful when you wish to see how a website will look like when hosted on a different server without making any DNS changes to your domain.

The location of the hosts file, depending on the operating system that you are using, is:

  • Windows – SystemRoot > system32 > drivers > etc > hosts
    By default the system root is C:\Windows, so if you are using Windows, your hosts file is most probably: C:\Windows\System32\drivers\etc\hosts)
  • Linux – /etc/hosts
  • Mac OS X – /private/etc/hosts

Let’s say that you wish to resolve mydomain.com to the IP address 10.20.30.40. In this case you would need to open up the hosts file with a text editor and append the following line:
10.20.30.40 mydomain.com www.mydomain.com