Ssh – Amazon AWS localhost error: channel 3: open failed: connect failed: Connection refused

amazon ec2amazon-web-servicesssh

I have just made an AWS ubuntu instance with a private key. I managed to connect to it through ssh, but I can't connect to it in web browser with localhost.
I'm connecting through a windows computer and I want to connect to a ubuntu instance through the .pem key.

Command i used to connect in command prompt:

ssh -L 8080:localhost:8080 -i C:\Users\grege\keys\den_forsta.pem ubuntu@ec2-xx-xx-xxx-xx.eu-north-1.compute.amazonaws.com

Error messages that pop up repeatedly in command prompt when trying to connect through 'localhost:8080' in chrome browser:

channel 3: open failed: connect failed: Connection refused

and also

channel 4: open failed: connect failed: Connection refused

My security group in amazon AWS instance is: HTTP, HTTPS and ssh, and source for them all are set to 'anywhere'.

I have tried exchanging 'localhost' for 127.0.0.1 and read other solutions but it does not work.
The solution can have to do with making key .ppk through PuTTYgen since it mentioned in the tutorial, but I can't figure out how, since they never mention it again.

I have tried opening port 8080 in firewall advanced settings and also added Custom TCP security rule that is open for port 8080.

Thanks a lot for answers. Ask if you need more info.

Best Answer

What exactly do you expect to see in the browser when you go to localhost:8080?

The command that you use ssh -L 8080:localhost:8080 ... forwards your local machine port 8080 to the remote machine and there it connects to its localhost:8080.

If you had some application running on port 8080 on the remote machine you could access it this way over ssh tunnel. Do you have something running on that port on your Ubuntu server?

Or is it perhaps running on port 80 instead? In that case your command should be ssh -L 8080:localhost:80 - that forwards local port 8080 to the remote machine’s port 80.

The main question is have you got some web app running on the Ubuntu server? And if so on what port? Once we figure that out we can discuss how to get there.

Hope that helps :)