Warthaxx
Warthaxx

Reputation: 53

Connect Laravel App on Heroku to my external MySql Database

I have uploaded my Laravel project to Heroku and I want to use my own database. It is hosted on a VPS. I have been using that DB from my computer and it worked fine but when I deploy my app it throws a Connection time out error.

I have used the following command to set up the connection:

heroku config:add DATABASE_URL=mysql://user:pass@server:port/database_name

Any idea on how can I achieve this? Or what am I doing wrong?

Thanks!!!!

Upvotes: 1

Views: 476

Answers (1)

Leonardo Rossi
Leonardo Rossi

Reputation: 3032

Laravel doesn't know by default how to use the DATABASE_URL environment variable you are setting.

I think you should probably run these commands

heroku config:add DB_HOST=server
heroku config:add DB_PORT=port
heroku config:add DB_USERNAME=user
heroku config:add DB_PASSWORD=pass
heroku config:add DB_DATABASE=database_name

Of course, change the values accordingly with your server configuration.

Upvotes: 1

Related Questions