Is there a particular reason for using MS SqlServer?
If it's possible you should move to MySQL/MariaDB or PostgreSQL since they are all pretty much the standard for Laravel.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey guys, found this other thread with the same issue
https://laracasts.com/discuss/channels/laravel/cannot-connect-to-mssql-laradock
it says alias is missing from network in docker-compose.yml
but whe i enter an alias it gives me an error Array is required. Scalar value not allowed
docker-compose.yml
### MSSQL ################################################
mssql:
build:
context: ./mssql
environment:
- MSSQL_PID=Express
- MSSQL_DATABASE=${MSSQL_DATABASE}
- SA_PASSWORD=${MSSQL_PASSWORD}
- ACCEPT_EULA=Y
volumes:
- mssql:/var/opt/mssql
ports:
- "${MSSQL_PORT}:1433"
networks:
backend
aliases:
-mssql
this is in the laradocs .env:
### MSSQL #################################################
MSSQL_DATABASE=mssql
MSSQL_PASSWORD="mssql"
MSSQL_PORT=1433
this is in the laravel .env, not sure what to put as username though:
DB_CONNECTION=sqlsrv
DB_HOST=mssql
DB_PORT=1433
DB_DATABASE=mssql
DB_USERNAME=root
DB_PASSWORD="mssql"
Im not sure what I am missing
EDIT PS** inspecting the network now, it does have mssql as alias, so that other thread is of not use
here is th error
[ERROR] Connection failed: SQLSTATE[HYT00]: [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired
Please or to participate in this conversation.