4

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.

  • 1
    There needs to be something listening **on port 8080** on the AWS instance – HBruijn Feb 15 '19 at 09:30
  • 2
    Possible duplicate of [What causes the 'Connection Refused' message?](https://serverfault.com/questions/725262/what-causes-the-connection-refused-message) – HBruijn Feb 15 '19 at 09:31
  • I have tested their solutions, opening a port on 8080 on AWS and allowing port 8080 on firewall, still does not work – Gabriel Petersson Feb 15 '19 at 09:53
  • Maybe I wasn't clear earlier but the problem looks like it is not so much a firewall issue (by port forwardiong over SSH you are bypassing the firewall anyway) , but rather that your web- or application server is not accepting incoming connections on port 8080 (typically a webserver listens on port 80 for http and 443 for https) so – HBruijn Feb 15 '19 at 10:08
  • @HBruijn Oh alright, do you know happen to know how to open that on the AWS instance? – Gabriel Petersson Feb 15 '19 at 10:16

1 Answers1

2

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 :)

MLu
  • 23,798
  • 5
  • 54
  • 81
  • 1
    Im doing the advaned machine learning nlp course on coursera, and they that the command is expected to make it able to open IPython notebook, and i have no clue how or why. I havr opened SSH, HTTP and HTTPS port on 80 and 443, and also i added a "custom TCP" on port 8080(not sure what that is tho). I will try the 80 port as you said when i get home. Thanks alot for the suggestions! – Gabriel Petersson Feb 15 '19 at 11:56