I'm trying to connect to a sql server database from Laravel 10 deployed on ubuntu 22.04. but I keep getting the following error: SQLSTATE[HYT00]: [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired
I installed the drivers to establish a connection to an sql server, following the Microsoft documentation. I also activated the php extensions sqlsrv and pdo_sqlsrv. I set the login timeout to 5 minutes. Despite all this, I still get the error.
However, I manage to connect to the database from the command line with sqlcmd and with a php file where I use pdo for the connection.
If anyone has a clue how to unblock this issue with Laravel, thank you in advance.
login timeout should be a couple of seconds at most. By making it 5 minutes you are forcing it to wait longer before giving up. There is something wrong with your credentials
My credentials works because I can connect to the database with Dbeaver and the same credentials.
I configured the .env with sqlsrv driver. I put the IP and the instance of the database as DB_HOST. And I put the the credentials as DB_USERNAME and DB_PASSWORD
@Snapey The database is stored in remote on the ip that I have in my .env file.
I set the same host and credentials on dbeaver and i works well. Also with sqlcmd on the VM that is deployed the laravel app. There is no filter on ip in the sql server host. So I don't see where could be the error
@Martial
I have the exact same issue, with the exact same configuration as you. I'm have been running this on an older version 18 ubuntu, msodbc 17 and it works fine. The newer setup times out. What exactly did you do to make it work?
Thanks
@Snapey
So when I run that on my local environment it runs fine, when I run it on my server it stops 1.2 way through and leaves me at a less prompt : I have to enter q to exit. I have made sure the config file and env file are the same, but I can't get it to work. Also it shows only the defaults in what it does show. Doesn't look like it's reading the env.
Thanks
Thanks, must be a server or driver issue. I discovered it works fine from my local environment, but not on the ubuntu server. I can ping it so I know it can get to it. Maybe I missed some configuration on the odbc driver that I didn't remember doing on the old server.