前提・実現したいこと
初投稿なのでエラー解決に必要な情報を理解しておりません情報が足りない場合は教えていただけるとありがたいです
3日間調べても解決できないので助けてほしいです...
cloud9でlaravel+mysqlで作ったwebアプリをHerokuで公開したい
https://qiita.com/JUM22676603/items/94e622a3e27b270112a8
上記の記事を参考にgit push heroku masterまで問題なく進みましたが
heroku run php artisan migrate実行中yesを入力したら以下のエラーがでました
発生している問題・エラーメッセージ
heroku run php artisan migrate Running php artisan migrate on ⬢ ifthen-woop-task... up, run.4952 (Free) ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > yes In PDOConnection.php line 31: SQLSTATE[08006] [7] could not translate host name "ホスト名:5432" to address: Name or service not known In PDOConnection.php line 27: SQLSTATE[08006] [7] could not translate host name "ホスト名:5432" to address: Name or service not known
heroku openのエラー
heroku open ▸ Error opening web browser. ▸ Error: Exited with code 3 ▸ ▸ Manually visit herokuアプリ名/ in your browser.
該当のソースコード
.env
APP_NAME=Laravel APP_ENV=local APP_KEY=base64:5ucJAW2DxKJ6m9mhUBOg7yTnWCV0dQzGXfirbe9Cz44= APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost DB_CONNECTION=mysql DB_HOST=**** DB_PORT=**** DB_DATABASE=**** DB_USERNAME=**** DB_PASSWORD=**** BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file SESSION_LIFETIME=120 QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1
config/database
<?php return [ /* |-------------------------------------------------------------------------- | Default Database Connection Name |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ 'default' => env('DB_CONNECTION', 'mysql'), /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', ], 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, ], 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', 'sslmode' => 'prefer', ], 'sqlsrv' => [ 'driver' => 'sqlsrv', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', ], ], /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk haven't actually been run in the database. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer set of commands than a typical key-value systems | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ 'client' => 'predis', 'default' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => 0, ], ], ];
heroku config
APP_DEBUG: true APP_KEY: base64:4QCMscH5Lp9uA1OvAMWl5L0+N/QTOj2cRYb93DuT3d4= DATABASE_URL: ユーザーネーム:パスワード@ホスト名:5432/データベース DB_CONNECTION: pgsql DB_DATABASE: /データベース DB_HOST: @ホスト名:5432 DB_PASSWORD: パスワード DB_USERNAME: ユーザーネーム
heroku logs
2021-01-19T02:13:00.211022+00:00 app[api]: Starting process with command `php artisan migrate` by user メールアドレス 2021-01-19T02:13:04.953063+00:00 heroku[run.4952]: State changed from starting to up 2021-01-19T02:13:05.380982+00:00 heroku[run.4952]: Awaiting client 2021-01-19T02:13:05.416769+00:00 heroku[run.4952]: Starting process with command `php artisan migrate` 2021-01-19T02:16:17.626966+00:00 heroku[run.4952]: Process exited with status 1 2021-01-19T02:16:17.696640+00:00 heroku[run.4952]: State changed from up to complete
試したこと
heroku apps:infoのweb urlからDBが必要ないページは表示されますがアカウント登録しようとすると上記のエラーが発生します
Herokuを使うのが初めてなので何が原因かあまり分かりませんが上記のエラー文を検索したところdockerなどの記事にあたりDBが起動していなかったりローカルでmigrateしていたりでエラーが発生しているのかな?と予想しています(的外れかもしれませんが...)
補足情報(FW/ツールのバージョンなど)
php 7.2.24
laravel 5.5.50
回答1件
あなたの回答
tips
プレビュー