You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS实例部署Jupyter Notebook后本地访问卡顿问题求助

Troubleshooting Local Access to AWS-hosted Jupyter Notebook via SSH Tunnel

Let's break down the most likely issues stopping you from accessing your Jupyter Notebook locally, and walk through fixes step by step:

1. Fix Your Incomplete SSH Tunnel Command

Looking at the command you shared:

ssh -i keypair.pem -L 8157:127.0.0.1:8888 ubuntu@

This command is missing a critical piece—your EC2 instance's public IP address or DNS name at the end. Without that, SSH can't connect to your instance at all, so no tunnel is established.

Update the command to include your instance's public IP (replace 3.14.159.26 with your actual instance IP):

ssh -i keypair.pem -L 8157:127.0.0.1:8888 ubuntu@3.14.159.26

First, make sure your keypair file has the correct permissions (required for Linux/macOS):

chmod 400 keypair.pem

2. Use the Correct Protocol for Local Access

Your Jupyter output clearly shows it's running over HTTP, not HTTPS:

The Jupyter Notebook is running at: http://localhost:8888/?token=...

You're trying to access https://127.0.0.1:8157, which will cause your browser to hang—Jupyter doesn't serve HTTPS by default. Switch to the HTTP version of the URL:

  • Basic address: http://127.0.0.1:8157
  • Token-protected address: http://127.0.0.1:8157/?token=4b35857968acb4a75dc4b7fdd246c20b967dcfaaa13799c2

3. Verify the SSH Tunnel Is Active

After running the corrected SSH command, confirm the tunnel is listening on your local port 8157:

  • Linux/macOS: Run this in a new terminal window:
    lsof -i :8157
    
    You should see an ssh process listed with LISTEN status.
  • Windows: Open Command Prompt and run:
    netstat -ano | findstr :8157
    
    Look for a result where the "State" is LISTENING, and the PID corresponds to ssh.exe (check PID details in Task Manager if needed).

If no results appear, double-check:

  • Your EC2 instance is running and has a valid public IP.
  • Your security group allows inbound SSH (port 22) from your local IP (your screenshot shows SSH is open to 0.0.0.0/0, which works for testing).

4. Check for Local Firewalls on the EC2 Instance

Ubuntu's default firewall (ufw) is usually disabled, but it's worth verifying:

  1. SSH into your EC2 instance.
  2. Run:
    sudo ufw status
    
  3. If it shows active, either allow loopback access to port 8888:
    sudo ufw allow in from 127.0.0.1 to any port 8888
    
    Or temporarily disable ufw to test:
    sudo ufw disable
    

5. Confirm Jupyter's Binding Address

From your output, Jupyter is correctly bound to localhost:8888, which works with your SSH tunnel. If you've modified Jupyter's config before, double-check the ip setting:

  1. SSH into your instance and open the config file (if it exists):
    nano ~/.jupyter/jupyter_notebook_config.py
    
  2. Look for the line:
    c.NotebookApp.ip = 'localhost'
    
    If it's set to a specific public IP instead, change it back to localhost or 0.0.0.0 (both work with the tunnel).

Start with the first two fixes—completing the SSH command and switching to HTTP—those are the most likely culprits here!

内容的提问来源于stack exchange,提问作者John Montague

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:19:58