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

EC2上部署Rails:Puma有响应但浏览器页面始终无法加载

Troubleshooting Puma Not Loading in Browser on EC2 Ubuntu 16.04 + Rails 5.1.6

Hey there! Let’s work through this together — I’ve dealt with similar EC2/Rails connectivity headaches before, so here are the most common fixes to check:

1. Fix EC2 Security Group Port Access

This is the #1 culprit for "server runs but browser can’t connect" scenarios. AWS blocks inbound traffic by default, so you need to open up the Rails development port (3000):

  • Head to your AWS EC2 console, select your instance, and go to the Security Groups tab
  • Edit inbound rules, add a new rule:
    • Type: Custom TCP
    • Port range: 3000
    • Source: Either 0.0.0.0/0 (for public access) or your specific IP address (more secure)
  • Save the rules and try accessing your instance’s public IP:3000 again.

2. Bind Puma to All Network Interfaces

By default, Rails starts Puma bound only to localhost (127.0.0.1), which means it’s only accessible from inside the EC2 instance, not your browser.

  • Start your server with this command instead:
    rails s -b 0.0.0.0
    

This tells Puma to listen on all available network interfaces, making it reachable from outside the instance.

3. Verify Puma’s Status and Check Logs

Let’s make sure Puma is actually running and not silently failing:

  • Check for active Puma processes:
    ps aux | grep puma
    
  • If it’s running, dig into the Rails development logs for errors:
    cat log/development.log
    

Look for red flags like database connection issues (even new projects can hit SQLite permission problems) or routing errors. Also, avoid running Puma in the background at first — keep it in your terminal to see real-time output.

4. Check Ubuntu’s UFW Firewall

Ubuntu 16.04 comes with UFW enabled by default, which might be blocking port 3000:

  • Check UFW’s current status:
    sudo ufw status
    
  • If it’s active, allow port 3000:
    sudo ufw allow 3000
    sudo ufw reload
    

5. Confirm Listen Gem Compatibility

You mentioned installing listen v3.1.5 — Rails 5.1.6 requires ~>3.1.0, so that version is compatible, but sometimes gem dependencies can get messed up:

  • Reinstall your bundle to ensure all gems are properly set up:
    bundle install
    

Then restart your Rails server to apply any changes.

A quick note: If this were a production setup, you’d want to use Nginx as a reverse proxy with Puma, but for a test app, the above steps should get you up and running.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:54:34