Laravel can't access database - heroku

I cvurrently have a laravel application running on heroku, the issue here is, I keep getting the error that I can't connect to the database: SQLSTATE[HY000] [1045] Access denied for user 'user'#'ec2-54-74-209-179.eu-west-1.compute.amazonaws.com' (using password: YES). Now the host is wrong here, the environment files are TOTALLY different (except for the username) then what the error gives....
How can I resolve this issue?
I've tried to use the DB_URL env, but that gives the same result...

Did you set the .env correctly on what's running on their server?
You can see all your projects in laravel at TOOLS->DEPLOYEMNT->CONFIGURATIONS
add all the info and connect to the remote project. I did the same and changed the .env directly there.
and of course you have to clean all the cache cause even if you change the .env it will not work until you'll clear it
php artisan cache:clear;
php artisan config:clear;
php artisan route:clear;
Obviously this need to be executed on the project on heroku or aws (as it appears from the Error)

Related

Laravel app not connecting after deployment to live server

After deploying my Laravel app to inMotion hosting, I am having issues connecting to the database. What is strange is that if I use a PHP script to test the connection, it works. However, when trying to login I get this error:
SQLSTATE[HY000] [1045] Access denied for user #'localhost' (using password: YES) (SQL: select * from `users` where `email` = .com limit
I am using the exact same username and password in the .env file as I did in the PHP test script. I have tried clearing the cache and also changing the password for the database as well as my username.
Turns out it was the password in the .env file. It had special characters, so I had to add quotation marks around it.
Better if you can clear the config cache and see. You can use the following command to clear the config cache in Laravel:
php artisan config:cache

Laravel is using the default homestead user details to connect, even though these have been deleted

I am using laravel 5.8.6 and can connect to my database using the artisan migration tool, and can read and write to the database using tinker with no issues.
When I launch the default scaffolding it fails to connect, complaining that the login failed for user homestead#localhost.
I have deleted the .env.example file and cleared the various cache files with no success.
A full search for homestead only reveals log entries:
Illuminate \ Database \ QueryException (1045)
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from `users` where `email` =
Any ideas gratefully received.
I had the exact same problem and I just couldn't wrap my mind around how that was even possible. Turns out I seem to have changed the .env file after having started the dev server via php artisan serve. It doesn't pick up changes in the .env config at runtime and it caches the configuration.
After running
php artisan config:clear
, shutting down the dev server and restarting it, the issue was resolved and the database connection successful with the correctly set database credentials.

Whoops, looks like something went wrong. on server

I uploaded all laravel project on server, its working fine on local but getting error on server, even database configuration and key is configured in env. file. even i renamed .env.example file as .env too but got same error.
Error is
"Whoops, looks like something went wrong."
my error log is here:
[2017-11-06 15:19:07] local.ERROR: exception 'RuntimeException' with
message 'The only supported ciphers are AES-128-CBC and AES-256-CBC
with the correct key lengths.' in
/home/rndspot5/public_html/dev/lea/vendor/laravel/framework/‌​src/Illuminate/Encry‌​ption/Encrypter.php:‌​43
Judging from your error, you need to run php artisan key:generate this will update your key of which in turn will rectify your error.
You will need to either SSH into your public_html folder if you have host permission to do so. Alternatively, you can ask your host provider to either:
Grant you SSH access
Perform this action for you.
You can then run: php artisan config:clear once the new key has been generated.
If you are on shared hosting you can use these steps
Open your .env file, copy APP_KEY to somewhere else as a backup
Run php artisan key:generate from console
Copy the new APP_KEY and upload it to the .env file on your (shared) server
Move the old key back to development
I resolved this issue, by adding web app url in .env and Config/App.php and now its working :) thanks all of you for sharing such a value able knowledge that will help me, may be later.

Laravel 5.4 Token Mismatch Exception on live server

I am facing Token mismatch exception in Laravel 5.4 on live server. On my local machine running Windows XAMPP, the application works fine. When I deployed it to live machine running CENTOS 7 and LAMP stack, I see a redirecting to myhostname.com/login at the top left corner of the browser and then lands on an error page showing:
token mismatch exception on line 68 of VerifyCsrfToken.php.
I had this same problem and what i did was:
First in your .env file remove: SESSION_DOMAIN
And in set session driver like: SESSION_DRIVER=file (if your want it to save to a file)
then do: php artisan cache:clear
then `php artisan config:clear
that worked for me.
Try to clear config cache on the server with :
artisan cache:config
You will need to clear config cache also if you edited config/app.php for some reason.
In addition there is an other possible reason : you copied not only the application but also the cache/session files when you deployed your application to production. Basically everything in the storage folder should be ignored on deployment.
Run this command
php artisan config:clear
Verify .env file
delete current .env file and create new .env file from .env.example
verify that config/session.php has is correct or not modified.
You can check the file permission as well of storage directory

laravel 5 - when trying to retrive data from phpmyadmin: SQLSTATE HY000 1698 Access denied for user 'root'#'localhost'

That's my first post - I hope my problem explanation will be easy to understand. I just started with Laravel5.
I want to retrive data from mysql database that was successfully created using migrations. I'm following laracast series. I created route, controller and view to display the data. Unfortunatelly, when I enter browser to see it, I constantly get this error:
`SQLSTATE[HY000] [1698] Access denied for user 'root'#'localhost'`
enter image description here
My .env and database.php files are configured. Also, I can do migrations with no error (and I see result in phpmyadmin to which I can log in). When I type php artisan tinker, I can do various operations on my databases. The problem arises only when I want to display data in my laravel site.
I did vast research of the problem and tried numerus tips like:
1.change local host to 127.0.0.1
2.change my database login and pass for homeostead, secret
3.I did
`GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY 'Your_Password';`
When I type mysql --user=root -p I can log in but command show databases acts like never ending and shows nothing.
and other ...
Now, I'm at loss for ideas what to do next, please help me. I will appreciate that a lot cos I'm really stucked at this point!
my .env file:
`DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=haslo`
I use homeostead and Laravel 5 on Windows 7
Server type: MySQL5.7.15
PHP version: 7.1
Apache/2.4.23, PHP/7.1
have a look at my answer at Unable to connect to local MySQL DB using Laravel
That could be the answer for you as well.
If you use homestead with vagrant, then laravel will be lunched inside vagrant and 127.0.0.1,3306 will mean the mysql inside vagrant, type vagrant ssh and check for the database.
Try this command:
Php artisan config:clear

Resources