-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLSTATE[HYT00]: [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired on Docker php:7.2-fpm #1014
Comments
Hi @AimDiab this might be related to #302 Let's try to tackle one problem at a time. To try to connect to your SQL Server 2017 Linux in docker: What's the output of the following command?
If the above works, you should see an output similar to this one below:
In your php scripts, try using For your local SQL Server, have you made sure that "it is configured to allow remote connections"? |
For some reason when I put my password in the command it fails to connect: But when I leave it out and enter it when it is prompted:
I'm copying and pasting my password in both cases, and I'm 100% sure it's correct. I have tried using Does the dockerized sql server need to be configured to allow remote connections as well then? I'll install SSMS and follow the steps in that URL. Edit: |
Hi @AimDiab, since your sql server linux is in a different docker container from where you have installed PHP and the drivers, I suppose you have linked them? FYI, you can check how to link containers About your password problem, from your info above, I figure your password contains |
Hi @yitam I noticed in #302 someone mentioned docker mapped their container to 0.0.0.0 instead of localhost. I checked the port mapping using I have not linked the containers. I will link them and attempt to connect again. Yes, my password contains several special characters. Thank you for the resources. |
@AimDiab I suggested using This documentation might help you troubleshoot. For now, perhaps you can try using a password without the special characters first. |
@yitam Thank you for your help! I really appreciate it.
It's also worth mentioning: The app I'm connecting to sql server is running CAKE PHP 2.10. After I was able to make the connection in PHP, I attempted using those credentials to make the connection in CAKE's database.php model. I ran into some issues with that. I was still getting I'm guessing there's an issue with CAKE (2.10)'s SQL SERVER database adapter that causes this error when attempting to connect to the newest SQL SERVER 2017. My work around was to go into The reason I'm including the above information is because it was frustrating for me, running around the internet and reading posts about connecting SQL SERVER to CAKE PHP and not finding a fix that worked for me. This will hopefully help anyone attempting to do the same thing as me. |
Thanks @AimDiab glad to hear that you have figured it out now. I used linking before so that should also work. I don't know much about CAKE PHP but thanks for the info. Yes some people might find this useful. |
DB_CONNECTION=sqlsrv |
Hi @Hossien-Salamhe we need more details than what you've provided. Please create a new issue to provide more info for us to investigate the problem, and if you like you can reference this issue. |
@yitam , @AimDiab thank you, the details you shared worked for me too. I was in the same case, the containers were different and also on different networks so it was throwing timeout. I had to check the container network for my PHP/Laravel app via And register the SQL Server container within that network via |
PHP Driver version or file name
PDO
SQL Server version
SQL SERVER 2017 DOCKER IMAGE, SQL SERVER 2017 EXPRESS
Client operating system
WINDOWS 10 running Docker php:7.2-fpm image
PHP version
7.2.19
Microsoft ODBC Driver version
ODBC Driver 17 for SQL Server
Table schema
new server, master database
Problem description
Can't connect from PHP(served using nginx) running inside a docker container (php:7.2-fpm) to SQL SERVER running inside docker container (mcr.microsoft.com/mssql/server:2017-latest) or even SQL Server Express running locally on my windows 10 machine.
Expected behavior and actual behavior
I would expect that I could make a database connection since I've installed all the requirements carefully. But I get a login timeout error every time.
Repro code or steps to reproduce
Some background:
I've ran all of this in my docker container (php:7.2-fpm) to get the drivers installed and enabled:
I've created my sql server docker container and ran it. Docker ps shows it running, and I can connect to it using Azure Data Studio and run queries. I've installed sql server express on my windows 10 and created a login, user and password and confirmed they are in there, and ran queries successfully in the sqlcmd that opens when you install sql server.
I've tried connecting using PDO to the dockerized sql server:
AND using PDO to the local one running on my machine:
Which both result in:
I've tried using the most basic php described in the php documentation:
AND:
Which results in:
And:
I've also read every dozens of posts including other issue posts on this board with the same error message and none of the solutions posed have worked.
The text was updated successfully, but these errors were encountered: