【问题标题】:Heroku - Application ErrorHeroku - 应用程序错误
【发布时间】:2011-12-18 17:31:06
【问题描述】:

我已经使用 Ruby on Rails 创建了简单的应用程序,并尝试在 Heroku 上提交它。我关注了这个Getting Started on Heroku guide, 我完成它并尝试打开我的页面,但我仍然看到一个错误: 应用程序错误:

应用程序发生错误,您的页面无法访问 服务。请稍后再试。

如果您是应用程序所有者,请查看您的日志以了解详细信息。

有人知道怎么处理吗?


我不知道发生了什么,但我已经完成了这一步,不幸的是我遇到了另一个问题,我运行了一些命令:

# git add .
# git commit -m "我的提交"
在分支 master 上无需提交(工作目录干净)
# git push heroku 掌握一切都是最新的
# heroku 打开 打开 http://eerie-meadow-9207.heroku.com/
# heroku 重启 重新启动进程...完成
# heroku 打开 打开 http://eerie-meadow-9207.heroku.com/

我看到一条消息:

很抱歉,出了点问题。

我们已收到有关此问题的通知,我们会尽快查看。

来自heroku logs[为清楚起见删除了时间戳]

app[web.1]: Started GET "/" for 77.236.11.34 at 2011-10-31 11:50:38 -0700
app[web.1]:   Processing by StoreController#index as HTML
app[web.1]: Completed 500 Internal Server Error in 3ms
heroku[router]: GET eerie-meadow-9207.heroku.com/ dyno=web.1 queue=0 wait=0ms service=13ms status=500 bytes=728
heroku[nginx]: 77.236.11.34 - - [31/Oct/2011:11:50:38 -0700] "GET / HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.2.23) Gecko/20110921 Ubuntu/10.04 (lucid) Firefox/3.6.23" eerie-meadow-9207.heroku.com
app[web.1]:
heroku[web.1]: State changed from up to bouncing
heroku[web.1]: State changed from bouncing to created
heroku[web.1]: State changed from created to starting
heroku[web.1]: Starting process with command `thin -p 40376 -e production -R /home/heroku_rack/heroku.ru start`
heroku[web.1]: Process exited
app[web.1]: >> Maximum connections set to 1024 
app[web.1]: >> Listening on 0.0.0.0:40376, CTRL+C to stop
app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
heroku[web.1]: State changed from starting to up
app[web.1]:
app[web.1]: Started GET "/" for 77.236.11.34 at 2011-10-31 11:50:59-0700
app[web.1]:
app[web.1]:   Processing by StoreController#index as HTML
app[web.1]: Completed 500 Internal Server Error in 4ms
app[web.1]:
app[web.1]: ActiveRecord::StatementInvalid (PGError: ERROR:  relation "products" does not exist
app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
app[web.1]:         ON a.attrelid = d.adrelid AND a.attnum = d.adnum
app[web.1]:              WHERE a.attrelid = '"products"'::regclass
app[web.1]:           AND a.attnum > 0 AND NOT a.attisdropped
app[web.1]:              ORDER BY a.attnum
app[web.1]: ):
app[web.1]:   app/controllers/store_controller.rb:3:in `index'
app[web.1]:
app[web.1]:
app[web.1]: cache: [GET /] miss
heroku[router]: GET eerie-meadow-9207.heroku.com/ dyno=web.1 queue=0 wait=0ms service=81ms status=500 bytes=728
heroku[nginx]: 77.236.11.34 - - [31/Oct/2011:11:50:59 -0700] "GET / HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.2.23) Gecko/20110921 Ubuntu/10.04 (lucid) Firefox/3.6.23" eerie-meadow-9207.heroku.com
app[web.1]:
app[web.1]:
app[web.1]: Started GET "/" for 77.236.11.34 at 2011-10-31 11:54:00-0700
app[web.1]:   Processing by StoreController#index as HTML

我无法理解它,因为在我的上网本上它可以在本地主机上运行,​​有什么想法吗?

【问题讨论】:

  • 一个解决方案:heroku logs 在控制台中了解发生了什么
  • 你用了什么栈? 'heroku stack' 和哪个 rails 版本?
  • 这可以是任意数量的东西。您是否查看了日志或检查了您的代码是您要根据教程输入的内容?
  • HEROKU LOGS: 2011-10-31T13:07:19+00:00 heroku[router]: Error H10 (App crashed) -> GET eerie-meadow-9207.heroku.com/dyno=队列 = 等待 = 服务 = 状态 = 503 字节 = 2011-10-31T13:07:19+00:00 heroku[nginx]: 77.236.11.34 - - [31/​​Oct/2011:06:07:19 -0700]" GET / HTTP/1.1" 503 607 "-" "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.2.23) Gecko/20110921 Ubuntu/10.04 (lucid) Firefox/3.6.23" eerie- meadow-9207.heroku.com 2011-10-31T13:07:24+00:00 heroku[router]: Error H10 (App crashed) -> GET eerie-meadow-9207.heroku.com/favicon.ico dyno= queue =等待=服务=状态=503字节=
  • @apneadiving,“一个解决方案:heroku 日志...”,然后呢?对发生的事情的了解如何解决问题?日志没有显示解决方案。只有问题!

标签: ruby-on-rails heroku


【解决方案1】:

当我开始创建一个不和谐机器人并使其在线时,我遇到了这个问题。我发现这是因为使用了节点最新的当前版本(v17.1),为此我浪费了大约 2 天的时间,并尝试将节点版本降级到 v16.7。令我惊讶的是它起作用了!。

所以我建议您在检查时降级到 v16.7 或最新的 LTS 版本并安装当前的最新版本 https://nodejs.org/ca/blog/release/v16.7.0/

这是完整的代码

const { Client, Intents } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// WShen the client is ready, run this code (only once)
client.once('ready', () => {
    console.log('Ready!');
});

// Login to Discord with your client's token
client.login(token);
const http = require('http');
const PORT = process.env.PORT || 3000;

const requestListener = function (req, res) {
  res.writeHead(200);
  res.end('Bot is up and running');
}

const server = http.createServer(requestListener);
server.listen(PORT);
  setInterval(function() {
    http.get("http://<your app name>.herokuapp.com");
}, 300000); // every 5 minutes (300000)

注意:此代码的最后 3 行完全是额外的,它们所做的是阻止 heroku 每 30 分钟让应用进入睡眠状态

【讨论】:

    【解决方案2】:

    只需确保在数据库中,您已允许“任何 IP 地址”进行连接。这称为将 IP 地址列入白名单。示例:0.0.0/0。这是因为 Heroku 每次启动时都使用不同的 IP 地址。但是您可以稍后使用 Heroku 文档和您的数据库服务提供商的文档进行更改。

    https://i.stack.imgur.com/Ud2VJ.png

    您可以使用这张图片作为示例,它是 MongoDB Atlas 的屏幕截图

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题。查看您的 Procfile 并检查您是否在其中添加了正确的命令,例如 web: python run.py。我无法连接,然后我输入了命令heroku logs --tail 以查看问题所在,我发现在我的 Procfile 中我有一个类型错误,例如 >>>web: oython run.pyecho web: python run.py > Procfile

      【讨论】:

        【解决方案4】:

        尝试使用命令

        heroku run rake db:migrate

        【讨论】:

        • 这为我返回了语法错误,我丢失了。感谢您的提示。我永远不会从 heroku logs 命令中猜到。
        • 我遇到了类似的错误,example.com/users 在 railstutorial.org 的这一步提供了相同的 html 输出:railstutorial.org/book/toy_app#sec-demo_users_resource 并使用 heroku run rake db:migrate 解决了我的问题。谢谢!
        【解决方案5】:

        尝试使用heroku restart 重新启动您的应用。假设您的应用程序在本地运行良好,这应该可以解决问题。它为我解决了这个问题,因为我只重构了架构,而 db:reset 似乎没有解决问题。

        【讨论】:

        • 我在本地运行我的应用程序并且它可以工作。 Heroku restart 给出:重新启动进程...完成,接下来打开heroku,我看到同样的错误...我读到如果您多次使用命令HEROKU CREATE,这可能是一个问题。我创建了大约 6-7 个项目,但我已经从 HEROKU 网站上删除了所有这些项目。还有其他想法吗?
        • 查看我回答中的视频。首次将 3.1 应用上传到 heroku 资源不足,但视频会指导您阅读并解决错误。
        • 这对我有用。我已经让应用程序休眠了一段时间,因为没有任何改变,我对它为什么不起作用感到困惑。
        【解决方案6】:

        http://www.youtube.com/watch?v=p_3dIPgXgkg

        如果您已经构建了应用程序,请转到视频中他开始将示例应用程序推送到 heroku 的地方。不幸的是,第一次上传 3.1 应用程序时,heroku 很难解决错误。按照视频中的故障排除步骤,你会没事的。

        【讨论】:

        • 我会尝试 heroku db:reset 然后 heroku db:migrate 如果这些命令集不起作用,请尝试 heroku destroy 并使用 youtube 教程故障排除方法重新部署
        【解决方案7】:

        大多数情况下,heroku 问题是由于缺乏访问文件系统的权限。为了让您的应用程序在 heroku 上运行,您必须确保它不会尝试将任何内容写入磁盘(但在临时文件夹中)。

        典型的例子是js/css的编译过程,e.g.使用指南针,您可以在他们的知识库中找到解决方案:http://devcenter.heroku.com/articles/using-compass

        您应该进一步查看 heroku 日志,看看在应用程序启动时或第一次请求期间是否存在任何“权限被拒绝”问题。

        【讨论】:

        • 好的 - 已解决,但现在我有另一个问题 - 我已经编辑了我的帖子
        • 谢谢。配置指南针与 Heroku 一起工作对我有用。
        猜你喜欢
        • 2016-04-01
        • 2017-01-30
        • 2018-02-17
        • 2014-11-19
        • 2014-03-12
        • 2015-10-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多