I have an SQL Server Docker image called microsoft/mssql-server-linux which was used to spin up an SQL Server database. I have an API which I made outside of Docker and I've unsuccessfully tried to construct a connection string to connect to this database.
I have successfully connected to this database using Azure Data Studio just with the following connection settings
Connection Type: Microsoft SQL Server
Server: localhost
Username: (username I created)
Password: (password I created)
I created an API project using Feathersjs and am using sequelize as an ORM. Here is how I've been trying to create the connection.
const sequelize = new Sequelize(database, username, password, {
dialect: "mssql",
host: localhost,
encrypt: false,
logging: false,
operatorsAliases: false,
define: {
freezeTableName: true
},
dialectOptions: {
port: 1433
// instanceName: "NameOfTheMSSQLInstance"
}
});
I'm using port 1433 because when I ran 'docker ps' in the terminal, it had this information listed under port.
0.0.0.0:1433->1433/tcp
I know the username/password are correct because I'm successfully connecting through Azure Data Studio and have changed them in a docker a few times just to make sure it wasn't a credentials issue.
I'm getting the following error message when trying to connect
error: Unhandled Rejection at: Promise {"_bitField":18087936,"_fulfillmentHandler0":{"name":"SequelizeConnectionError","parent":{"message":"Failed to connect to 172.17.0.2:1433 in 15000ms","code":"ETIMEOUT"},"original":{"message":"Failed to connect to 172.17.0.2:1433 in 15000ms","code":"ETIMEOUT"}},"name":"SequelizeConnectionError","parent":{"message":"Failed to connect to 172.17.0.2:1433 in 15000ms","code":"ETIMEOUT"},"original":{"message":"Failed to connect to 172.17.0.2:1433 in 15000ms","code":"ETIMEOUT"}} error: GeneralError: Failed to connect to 172.17.0.2:1433 in 15000ms