質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.51%
Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

1回答

547閲覧

herokuでWebページをデプロイしたらApplication error になってしまう

koikoikoikoi

総合スコア14

Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

0クリップ

投稿2022/09/25 12:04

編集2022/10/08 06:12

前提

初心者です。
rails tutorialで学習中です。
cloud9のターミナルで git push heroku master した後、herokuでopen app しても

Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail

と表示されてしまいます。

実現したいこと

Application errorを改善し、正常にWebページを表示させたい

発生している問題・エラーメッセージ

$ git push heroku master Counting objects: 3, done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 304 bytes | 304.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-22 stack remote: -----> Using buildpack: heroku/nodejs remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: USE_YARN_CACHE=true remote: NODE_VERBOSE=false remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: remote: -----> Installing binaries remote: engines.node (package.json): 14.19.0 remote: engines.npm (package.json): 6.x.x remote: engines.yarn (package.json): unspecified (use default) remote: remote: Resolving node version 14.19.0... remote: Downloading and installing node 14.19.0... remote: Bootstrapping npm 6.x.x (replacing 6.14.16)... remote: npm 6.14.17 installed remote: Resolving yarn version 1.22.x... remote: Downloading and installing yarn (1.22.19) remote: Installed yarn 1.22.19 remote: remote: -----> Restoring cache remote: - yarn cache remote: remote: -----> Installing dependencies remote: Installing node modules (yarn.lock) remote: yarn install v1.22.19 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: [3/4] Linking dependencies... remote: [4/4] Building fresh packages... remote: Done in 7.93s. remote: remote: -----> Build remote: remote: -----> Pruning devDependencies remote: yarn install v1.22.19 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: [3/4] Linking dependencies... remote: [4/4] Building fresh packages... remote: warning Ignored scripts due to flag. remote: Done in 2.67s. remote: remote: -----> Caching build remote: - yarn cache remote: remote: -----> Build succeeded! remote: ! This app may not specify any way to start a node process remote: https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type remote: remote: -----> Discovering process types remote: Procfile declares types -> (none) remote: Default types for buildpack -> web remote: remote: -----> Compressing... remote: Done: 47.8M remote: -----> Launching... remote: Released v7 remote: https://fathomless-shore-68344.herokuapp.com/ deployed to Heroku remote: remote: Starting November 28th, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® will no longer be available. remote: remote: If you have apps using any of these resources, you must upgrade to paid plans by this date to ensure your apps continue to run and to retain your data. For students, we will announce a new program by the end of September. Learn more at https://blog.heroku.com/next-chapter remote: remote: Verifying deploy.... done. To https://git.heroku.com/fathomless-shore-68344.git 6d8a917..36e2237 master -> master

該当のソースコード

試したこと

$ heroku run rails c で

Running rails c on xxxxx... up, run.4868 (Free) /usr/bin/env: 'ruby': No such file or directory

と表示されたのでググったら改行コードを
CRLFからLFに変更したら良いと書いてありましたがMacではデフォルトでLFに設定されてるのでこれは的外れ。
他にも heroku run rails c で出た上記エラーで様々な解決策を調べたが解決策が見つからず、、

どなたかご教授お願いいたします。

参考

https://qiita.com/nishikawa1031/items/38132298ef7c34a3b7b2
https://qiita.com/ryonishimura37/items/b72ecc829f9501857528

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

herokuの無料プランは終了したので、アップグレードしましょうということです。

remote: Starting November 28th, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® will no longer be available.
remote:
remote: If you have apps using any of these resources, you must upgrade to paid plans by this date to ensure your apps continue to run and to retain your data. For students, we will announce a new program by the end of September. Learn more at https://blog.heroku.com/next-chapter


ここからは余談ですが…
以前のHerokuと同じようなPaaSの移行先で考えると無料枠のあるrender.comとfly.ioなどになるかと思います。
個人的なおすすめとしては、応答速度が早くて、デプロイも簡単だったのでfly.ioです!あくまで個人の意見ですが・・・
https://qiita.com/yuuki-h/items/ec23de152368d36672ea

投稿2022/09/25 12:13

no1knows

総合スコア3365

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

koikoikoikoi

2022/09/25 12:29

ありがとうございますm(._.)m
koikoikoikoi

2022/09/25 12:41

エラー文によるとherokuの無料プランはまだ終わってなくて11月28日までは使えますよね??
no1knows

2022/09/26 00:49

あとベストアンサーは外してください! またログを確認してもわからない場合は、再度、追記頂ければ確認させていただきます。 お手数をおかけして申し訳ありません。
koikoikoikoi

2022/09/27 11:24

まだ解決できていませんm(._.)m また新たにpushしたので一応ログをもう一度貼り付けます(ほとんど変わってないと思いますが、、) ``` -----> Building on the Heroku-22 stack -----> Using buildpack: heroku/nodejs -----> Node.js app detected -----> Creating runtime environment NPM_CONFIG_LOGLEVEL=error USE_YARN_CACHE=true NODE_VERBOSE=false NODE_ENV=production NODE_MODULES_CACHE=true -----> Installing binaries engines.node (package.json): 14.19.0 engines.npm (package.json): 6.x.x engines.yarn (package.json): unspecified (use default) Resolving node version 14.19.0... Downloading and installing node 14.19.0... Bootstrapping npm 6.x.x (replacing 6.14.16)... npm 6.14.17 installed Resolving yarn version 1.22.x... Downloading and installing yarn (1.22.19) Installed yarn 1.22.19 -----> Restoring cache - yarn cache -----> Installing dependencies Installing node modules (yarn.lock) yarn install v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... Done in 9.10s. -----> Build -----> Pruning devDependencies yarn install v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... warning Ignored scripts due to flag. Done in 2.54s. -----> Caching build - yarn cache -----> Build succeeded! ! This app may not specify any way to start a node process https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type -----> Discovering process types Procfile declares types -> (none) Default types for buildpack -> web -----> Compressing... Done: 47.8M -----> Launching... Released v8 https://fathomless-shore-68344.herokuapp.com/ deployed to Heroku Starting November 28th, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® will no longer be available. If you have apps using any of these resources, you must upgrade to paid plans by this date to ensure your apps continue to run and to retain your data. For students, we will announce a new program by the end of September. Learn more at https://blog.heroku.com/next-chapter ```
no1knows

2022/09/27 11:45

v7と同じであればデプロイまでは完了しているので、heroku logs --tailを使ってどこでエラーが起きているのか確認・修正するのが良いかと思います! デプロイ先のURLの英語は下記のような意味になります。(deeplで翻訳) アプリケーションにエラーが発生し、ページを提供することができませんでした。あなたがアプリケーションの所有者であれば、ログをチェックして詳細を確認してください。Heroku CLIから次のコマンドで確認できます。 heroku logs --tail
koikoikoikoi

2022/09/29 09:38

下記のサイトに Procfileを作成し web: node index.js を記述すれば解決すると書いてあったので実行しましたが別のエラーが出てきてしまいました、、 https://teratail.com/questions/149944
koikoikoikoi

2022/09/29 09:40

``` $heroku logs --tail 2022-09-27T11:19:25.429742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fathomless-shore-68344.herokuapp.com request_id=80f4a59e-ab4a-485d-990f-2bad86af7a1f fwd="156.146.35.170" dyno= connect= service= status=503 bytes= protocol=https 2022-09-27T11:28:53.686261+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fathomless-shore-68344.herokuapp.com request_id=d1178c52-40cf-45ca-aadc-162171111f49 fwd="156.146.35.170" dyno= connect= service= status=503 bytes= protocol=https 2022-09-27T11:28:54.530109+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fathomless-shore-68344.herokuapp.com request_id=6589b966-65cd-4c66-9294-01d90944585b fwd="156.146.35.170" dyno= connect= service= status=503 bytes= protocol=https ※字数制限の為割愛 2022-09-27T11:39:03.981726+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fathomless-shore-68344.herokuapp.com request_id=c7dea03d-6485-4ef9-a88e-5a1820eacd94 fwd="156.146.35.170" dyno= connect= service= status=503 bytes= protocol=https 2022-09-27T15:42:39.579344+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-27T15:42:42.863340+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-27T15:42:44.356170+00:00 app[web.1]: npm ERR! missing script: start 2022-09-27T15:42:44.362295+00:00 app[web.1]: 2022-09-27T15:42:44.362433+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-27T15:42:44.362485+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-27T15_42_44_356Z-debug.log 2022-09-27T15:42:44.488708+00:00 heroku[web.1]: Process exited with status 1 2022-09-27T15:42:44.596272+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-27T18:16:45.608999+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-27T18:16:49.175447+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-27T18:16:50.835566+00:00 app[web.1]: npm ERR! missing script: start 2022-09-27T18:16:50.841448+00:00 app[web.1]: 2022-09-27T18:16:50.841597+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-27T18:16:50.841643+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-27T18_16_50_836Z-debug.log 2022-09-27T18:16:50.956922+00:00 heroku[web.1]: Process exited with status 1 2022-09-27T18:16:51.036539+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-27T20:17:09.845597+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-27T20:17:13.713641+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-27T20:17:15.434629+00:00 app[web.1]: npm ERR! missing script: start 2022-09-27T20:17:15.442596+00:00 app[web.1]: 2022-09-27T20:17:15.442743+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-27T20:17:15.442766+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-27T20_17_15_435Z-debug.log 2022-09-27T20:17:15.720939+00:00 heroku[web.1]: Process exited with status 1 2022-09-27T20:17:15.772583+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-28T00:00:05.627095+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-28T00:00:09.137208+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-28T00:00:10.742614+00:00 app[web.1]: npm ERR! missing script: start 2022-09-28T00:00:10.747874+00:00 app[web.1]: 2022-09-28T00:00:10.748017+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-28T00:00:10.748075+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-28T00_00_10_743Z-debug.log 2022-09-28T00:00:10.890627+00:00 heroku[web.1]: Process exited with status 1 2022-09-28T00:00:10.970157+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-28T05:34:46.738158+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-28T05:34:50.391709+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-28T05:34:51.849347+00:00 app[web.1]: npm ERR! missing script: start 2022-09-28T05:34:51.851744+00:00 app[web.1]: 2022-09-28T05:34:51.851897+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-28T05:34:51.851941+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-28T05_34_51_849Z-debug.log 2022-09-28T05:34:51.974330+00:00 heroku[web.1]: Process exited with status 1 2022-09-28T05:34:52.033174+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-28T11:34:55.046139+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-28T11:34:58.574051+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-28T11:35:00.099011+00:00 app[web.1]: npm ERR! missing script: start 2022-09-28T11:35:00.104375+00:00 app[web.1]: 2022-09-28T11:35:00.104525+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-28T11:35:00.104586+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-28T11_35_00_099Z-debug.log 2022-09-28T11:35:00.224223+00:00 heroku[web.1]: Process exited with status 1 2022-09-28T11:35:00.355310+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-28T17:03:07.139847+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-28T17:03:10.562012+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-28T17:03:12.213926+00:00 app[web.1]: npm ERR! missing script: start 2022-09-28T17:03:12.219849+00:00 app[web.1]: 2022-09-28T17:03:12.220073+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-28T17:03:12.220148+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-28T17_03_12_214Z-debug.log 2022-09-28T17:03:12.344262+00:00 heroku[web.1]: Process exited with status 1 2022-09-28T17:03:12.403952+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-28T22:50:37.930709+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-28T22:50:41.621115+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-28T22:50:43.630788+00:00 app[web.1]: npm ERR! missing script: start 2022-09-28T22:50:43.636305+00:00 app[web.1]: 2022-09-28T22:50:43.636533+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-28T22:50:43.636619+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-28T22_50_43_631Z-debug.log 2022-09-28T22:50:43.781331+00:00 heroku[web.1]: Process exited with status 1 2022-09-28T22:50:43.833316+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-29T04:42:47.113088+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-29T04:42:50.397810+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-29T04:42:52.194754+00:00 app[web.1]: npm ERR! missing script: start 2022-09-29T04:42:52.197188+00:00 app[web.1]: 2022-09-29T04:42:52.197339+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-29T04:42:52.197401+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-29T04_42_52_195Z-debug.log 2022-09-29T04:42:52.335100+00:00 heroku[web.1]: Process exited with status 1 2022-09-29T04:42:52.443456+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-29T09:21:46.000000+00:00 app[api]: Build started by user koichan1996@icloud.com 2022-09-29T09:22:39.663542+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-29T09:22:49.727248+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-29T09:22:52.196442+00:00 app[web.1]: npm ERR! missing script: start 2022-09-29T09:22:52.201802+00:00 app[web.1]: 2022-09-29T09:22:52.202011+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-29T09:22:52.202088+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-29T09_22_52_197Z-debug.log 2022-09-29T09:22:52.322556+00:00 heroku[web.1]: Process exited with status 1 2022-09-29T09:22:52.825835+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-29T09:22:52.834359+00:00 heroku[web.1]: State changed from crashed to starting 2022-09-29T09:23:01.182633+00:00 heroku[web.1]: Starting process with command `npm start` 2022-09-29T09:23:03.857801+00:00 app[web.1]: npm ERR! missing script: start 2022-09-29T09:23:03.862605+00:00 app[web.1]: 2022-09-29T09:23:03.862739+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-09-29T09:23:03.862803+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-09-29T09_23_03_858Z-debug.log 2022-09-29T09:23:04.009321+00:00 heroku[web.1]: Process exited with status 1 2022-09-29T09:23:04.099238+00:00 heroku[web.1]: State changed from starting to crashed 2022-09-29T09:23:05.049527+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fathomless-shore-68344.herokuapp.com request_id=000ea899-df59-4cd9-bf75-5ed0fdd5113a fwd="138.199.22.226" dyno= connect= service= status=503 bytes= protocol=https 2022-09-29T09:23:05.899592+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fathomless-shore-68344.herokuapp.com request_id=f3189283-3490-4efd-b6bb-1b2f8e217cd5 fwd="138.199.22.226" dyno= connect= service= status=503 bytes= protocol=https 2022-09-29T09:22:39.338415+00:00 app[api]: Deploy a47a9f2f by user koichan1996@icloud.com 2022-09-29T09:22:39.338415+00:00 app[api]: Release v9 created by user koichan1996@icloud.com 2022-09-29T09:22:43.000000+00:00 app[api]: Build succeeded ```
no1knows

2022/09/29 10:36

下記のアプローチはいかがでしょうか? > 一旦、別の Rails アプリを作成して Heroku に新しいリポジトリーを追加し、同様にデプロイしたところサーバーの起動まではうまくいった。 https://dhtakeuti.hatenablog.com/entry/2018/12/11/142638
yudukikun5120

2022/10/07 21:12 編集

web: node index.js は,Nodeで index.jsを実行するという意味ですよね? production環境で動かしたいのだから,web: の後には `rails s -e production` のようなコマンドが来ることが予測されませんか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.51%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問