typeorm: Failed to connect to localhost:1433 - Could not connect (sequence)
Issue type: [X ] question
Database system/driver:
[X] mssql
TypeORM version:
[X] latest
Hi everyone,
I’m new to typeorm. For now, I’m trying to connect to my local sql server which is:
Server name: .\SQLEXPRESS
Port: 1433 (default)
This is my configuration file (ormconfig.json):
{
"type": "mssql",
"host": "localhost",
"port": 1433,
"username": "sa",
"password": "mypassword",
"database": "HelloWorld",
"synchronize": true,
"logging": false,
"entities": [
"src/entity/**/*.ts"
],
"migrations": [
"src/migration/**/*.ts"
],
"subscribers": [
"src/subscriber/**/*.ts"
],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "src/migration",
"subscribersDir": "src/subscriber"
}
}
When I typed npm run start in my command prompt window, it threw me an error: Failed to connect to localhost:1433 - Could not connect (sequence)
If I connect to my database using SMSS tool, it worked normally.
I’ve tried following this solution to turn on TCP connection of my database, but it still didn’t work.
What am I doing wrong ?
Thank you.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18
Hi @IbraBach,
Try below steps:
Try this I hope this should work.
Finally I resolved my issue.
I forgot turning on
SQL Server Browserservice on my machine.I followed those steps to turning on SQL Server Browser.
I used
JetBrain DataGriptool to try to connect to my database, it detected my port was65269instead of1433.I think this issue can be closed.
I found this query on stack overflow
Maybe will help if you’re using Microsoft SQL Server Management Studio and you don’t know how to get the port.
const config = { user: ‘your-user’, password: ‘your-password’, server: ‘localhost’, database: ‘your-database’, options: { encrypt: false // please add this for ms sql } };