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

JustPy应用部署在AWS Lightsail Ubuntu虚拟机上无报错但页面无法显示问题求助

Troubleshooting JustPy App Not Loading on AWS Lightsail Ubuntu

First, let's confirm your code and JustPy env config look solid— setting HOST = '0.0.0.0' is exactly what you need to make the service accessible externally, and your hello-world app is a valid minimal test. The issue almost always boils down to network access restrictions, which are easy to fix. Here's the step-by-step breakdown:

1. Fix AWS Lightsail Firewall Rules (Most Likely Culprit)

Lightsail blocks all incoming ports by default except for SSH (22), HTTP (80), and HTTPS (443). Your app is running on port 8000, which isn't allowed by default:

  • Log into the AWS Lightsail console and select your Ubuntu instance
  • Navigate to the Networking tab
  • Scroll to the Firewall section and click Add rule
  • Set the following values:
    • Protocol: TCP
    • Port range: 8000
    • Source: 0.0.0.0/0 (or restrict to your specific IP for extra security)
  • Save the rule and wait 1-2 minutes for changes to take effect

2. Verify Ubuntu Local Firewall (UFW)

Even if Lightsail's firewall is open, Ubuntu's built-in UFW might be blocking the port:

  • SSH into your instance and run this to check UFW status:
    sudo ufw status
    
  • If UFW is enabled and you don't see a rule allowing port 8000, add it with:
    sudo ufw allow 8000/tcp
    
  • Recheck status to confirm the rule is active:
    sudo ufw status
    

3. Test Local Connectivity First

Before testing externally, confirm the app is actually responding on the instance:

  • Run this command on your Lightsail instance:
    curl http://localhost:8000
    
  • If you get an HTML response (look for <h1>Hello World!</h1> in the output), the app is working correctly. If not:
    • Check if port 8000 is in use by another process:
      sudo lsof -i :8000
      
    • Reinstall JustPy if there's a corrupt installation:
      pip3 uninstall justpy -y && pip3 install justpy
      

4. Ensure You're Using the Correct External URL

You mentioned having a static URL— make sure you're accessing the app with:

http://your-static-ip-or-domain:8000
  • Don't use http://0.0.0.0:8000 externally; that's only the internal listen address for the server
  • Don't forget the :8000 port suffix— browsers default to port 80/443, so omitting it will fail

5. Keep the App Running After SSH Disconnect (Optional)

If you close your SSH session, the app will stop. To keep it running in the background:

  • Use nohup to run it detached:
    nohup python3 run.py &
    
  • Check logs later with:
    cat nohup.out
    
  • For a more robust setup, create a systemd service to manage the app (auto-starts on reboot, easy to restart/stop)

内容的提问来源于stack exchange,提问作者Christian Walter

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 19:22:56