3

I have a Linux Ubuntu instance running on AWS EC2. On this instance I have a service running on localhost:8889, which means the service runs on port 8889 on the instance's localhost.

I want to access this localhost address from my Mac. I've already tried to access it using the following addresses but none has worked:

http://<public-dns>:8889
http://<public-ip>:8889
http://<private-ip>:8889

I've also tried to search for it in Google, but so far none if the methods worked for me, including associating an Elastic IP address to the instance and editing the Inbound and Outbound rules on the security group to allow the port to everyone.

I have read something about Port Forwarding but I'm not sure that I'm completely understanding it. I have understand the idea of it, but I didn't understand how to do it.

If you could please help me figure out how to access to the instance's localhost using port forwarding that would be great. I realized it has something to do with the terminal, but I didn't understand where I need to run the command (on the Mac or on the instance), and what are the parameters I need to use.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
Ido Naveh
  • 2,442
  • 3
  • 26
  • 57
  • can you add the security group associated to this instance ? you need to have an inbound rule on port 8889 allows to everybody – Frederic Henri Jul 09 '17 at 08:23
  • @FrédéricHenri I already have an inbound rule on port 8889 allowed to everyone. – Ido Naveh Jul 09 '17 at 08:26
  • https://serverfault.com/q/211536/45086 https://stackoverflow.com/q/28170004/251311 – zerkms Jul 09 '17 at 08:31
  • can you confirm the service is running ? `curl http://localhost:8889/` is working and how is it running, is it bound to localhost network interface only ? – Frederic Henri Jul 09 '17 at 08:45
  • @FrédéricHenri I tried to run the command you wrote (`curl http://localhost:8889/`) but nothing happened. Because nothing happened I wrote `wget` instead of `curl` to make sure it exists and it did download the page and saved it as `index.html`, so it is running. – Ido Naveh Jul 09 '17 at 08:51
  • and what is the service you're running ? how do you start it ? – Frederic Henri Jul 09 '17 at 08:53
  • @FrédéricHenri The service is `Jupyter`. I'm starting it using the command `jupyter notebook` and then I get a message saying the Jupyter Notebook is running at `http://localhost:8889/?token=token_id` when `token_id` is the token allowing me to access it for the first time – Ido Naveh Jul 09 '17 at 08:55

1 Answers1

2

In your case, the service jupyter-notebook is listening to localhost interface only so you'll not be able to access from the IP of the server.

A simple solution would be to start using a specific config.

$ Jupiter-notebook --config=jupyter_notebook_config.py

and in your jupyter_notebook_config.py file to have at minimum the property

c.NotebookApp.ip = "0.0.0.0"

You can review the doc for all details on possible config. By listening on 0.0.0.0 the service will be accessible on the different IP (duns, private or public IP)

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139