Can I connect Laravel on Heroku with Awardspace database? - laravel

I added in ENV file on Heroku informations from Awardspace, because I want to connect that database with Laravel project deployed on Heroku.
I am getting error SQLSTATE[HY000] [2002] Connection refused

you have these credentials you should put it in settings -> config vars->
DATABASE_URL
DB_CONNECTION=pgsql
DB_DATABASE
DB_HOST
DB_PASSWORD
DB_PORT
DB_USERNAME
after added these credentials with database
you should run in bash php artisan migrate
and work fine
hopefully that is help you

use this command for clear cache.
php artisan optimize:clear
php artisan optimize

Related

Connection could not be established with host mailhog :stream_socket_client()

I'm getting an error in mailhog while sending an email to new user for creating password.
Error:
Connection could not be established with host mailhog :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: No such host is known.
.env config:
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="dev#example.com"
MAIL_FROM_NAME="${APP_NAME}"
Do you use sail package for laravel? If you are using laravel sail you should set:
MAIL_HOST=mailhog
Otherwise it must be:
MAIL_HOST=localhost
Also enter a value for MAIL_FROM_ADDRESS:
MAIL_FROM_ADDRESS=a#gmail.com
In recent versions of Laravel Homestead, if you take a look at the Homestead.yml file, almost at the top you can get the IP address set for the Homestead Virtual Machine.
Copy that address to your .env file and set it instead of mailhog:
MAIL_HOST=192.168.56.56 #mailhog
Then you can access Mailhog with your browser by typing
http://192.168.56.56:8025/
This problem occurs when some changes have been made to files, specifically in .env file. I was facing the same issue and solved by this solution.
Clear cache using artisan command
php artisan cache:clear
Clear config
php artisan config:clear
Restart your server
sudo service apache2 restart
More: Try clearing browsers cache & cookies.

php artisan migrate throws received invalid response to SSL negotiation

I have a laravel app on nginx with postresql
php artisan migrate
throws error:
In Connection.php line 671:
SQLSTATE[08006] [7] received invalid response to SSL negotiation: b (SQL: select * from information_schema.tables where table_schema = publ
ic and table_name = migrations and table_type = 'BASE TABLE')
In Connector.php line 70:
SQLSTATE[08006] [7] received invalid response to SSL negotiation: b
FILES:
.env
...
DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=secretdbname
DB_USERNAME=secretusername
DB_PASSWORD=secretpassword
...
postresql.conf
...
port = 5432
...
in php.ini enabled:
pgsql
pdo_pgsql
mbstring
php -m
...
mbstring
openssl
PDO
pdo_mysql
pdo_pgsql
pgsql
...
Appropriate db exists, user exists and has got all the privileges.
Postgres service is active.
DB and app are located on the same server.
What I have tried:
setting up a different port in both .env and postgres.conf
tested with a different db, user and password
restarted postresql
in tinker DB::connection()->getPdo(); throws the same error
in DB_HOST tried 127.0.0.1. instead of localhost
in config/database.php i tried setting 'sslmode' to 'disable'
I have SSL certificate with certbot.
I would appreciate some hint on how to solve the above error.
Indeed, following Alex running
php artisan config:cache
helped, as it thrown a slightly different error which pointed me to the actual solution
SOLUTION:
postgresql.conf file has got this line:
listen_addresses = 'localhost'
commented by default, thus the solution is simply to uncomment it (as I mentioned in my original post, both DB and app are on the same server).
Hope it will save sb's time for the future.
I got the same error today with the Laravel 9.
The solution was to make sure the Postgress DB_Port inside .env is pointing to 5432.
Hope it will help others.

Laravel's "artisan serve" and connection to Homestead database

Why I can't connect to Homestead mysql when I use artisan serve build in server? Host, port is configured in .env to point at Homestead database.
Why I want artisan serve instead of Homestead server? I'm making Nuxt app with hotreload and I want to test in while on localhost:8000 port.
Right now I'm getting "SQLSTATE[HY000] [2002] Connection refused".
Oh after npm build on Homestead server connection to database working great... so it's not credentials problem.
Virtual machine IP... 192.168.10.10 instead of my main OS IP 127.0.0.1. Solved. Thanks to #devk.

Laravel 5.3 php artisan migrate not working

I'm new to laravel and I'm exploring how to do migrations. I created a new users table and when I run "php artisan migrate" it gives me "[PDOException] SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it." . I run "composer dump-autoload" then did "composer install" but no joy. I configured my .env file like below:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=francis
DB_USERNAME=homestead
DB_PASSWORD=secret
Mysql status:
I think MySql service is not active. You have to active MySQL service. Because it's unable to connect with DB.
Or I think disable proxy at web.config file try this.
<system.net>
<defaultProxy>
<proxy usesystemdefault="False"/>
</defaultProxy>
</system.net>

Laravel not connecting to homestead database

I was developing a laravel application locally on Mac connecting to a mysql database. i recently found out about homestead and pulled my app over to Vagrant Homestead. however now im not able to connect to the mysql server on the homestead/box.
Error i recieve:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES)
I did update my app's .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=eHDatabase
DB_USERNAME=homestead
DB_PASSWORD=secret
I cleared my app's cache
php artisan cache:clear
I updated my /etc/hosts file
27.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 laravel.app
and i also removed the old mysql server running on port 3306 on 127.0.0.1.
but still recieve the connection error.
Any help would be great.
Both .env and /config/database.php are looking fine, so try to run this:
php artisan config:cache

Resources