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

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.

Related

How to deploy Laravel project using Remote Desktop Connection and AWS and run the application on {MY_IP}:8000/

I had made an EC2 instance on my AWS and also established the connection with RDC in my local system.
Installed my required modules and set up the environment for the Laravel successfully.
Xampp is also installed and the database connection is established
And my project is running perfectly in that RDC system's Localhost on port 8000
My problem I am not able to run my solution on port 8000 when I am hitting the server with my IP.
Basically, no port other than port 80 is opening via IP
How can I open my project on port 8000 via my IPv4 or IP?
I have got the solution to this.
Instead of deploying the project on localhost:{my_ip} to deploy it at 0.0.0.0:{my_ip}
In Laravel run this command in the workspace ok the project, it will be reflected on the respective domain as well.
php artisan serve --host 0.0.0.0 --port 8000
--host defines the hostname of the project and port defines the port on which you are planning to deploy your source.
it solved my problem hope it will help !!!

Connect localhost from host virtualbox

I have a Laravel app in Virtualbox in the localhost aka 127.0.0.1:8000 and I want to connect from my host to the server.
Also, it will be great that anyone with the same network can connect to my localhost.
How can this be done?
You can pass the host while running the php artisan serve command.
For example, your network IP is 192.168.1.2
Then run the command like this
php artisan serve --host=192.168.1.2
Hope this will work for you.

Run laravel migration onto a remote host from a docker container

How to reliably run
php artisan migrate --env=staging
where .env.staging is setup with a remote hostname or ip in the DB_HOST field
OR
php artisan migrate --database=staging_db
where database.php has a staging_db with DB_HOST pointing to remote hostname or ip
Whenever I run it I receive this error:
[PDOException] SQLSTATE[08006] [7] could not connect to server: No
such file or directory Is the server running locally and accepting
connections on Unix domain socket
"/var/run/postgresql/.s.PGSQL.5432"?
Not sure whats causing it? most likely due to the container being on an internal network which doesnt recognize the remote hostname or IP. How do I solve this?

Laravel Homestead not working database connect

I have installed laravel homestead and run it.
But I can't run migration locally and in vagrant.
If I try to run the migration inside vagrant
cd ~/code/project/
php artisan migrate
I got an error
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 54320?"
If I try to run the migration locally I got a another error
PDOException::("could not find driver")
my .env file contains the same code as written in doc
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=54320
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Maybe something I do not understand but do I need posgresql locally and inside my vagrant? Where I have to work with database locally or with vagrant?

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