question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to connect with MSSQL

See original GitHub issue

I’ve modified settings.json as follows to enable MSSQL as the database storage technology.

I’m using a default, unnamed, installation of MSSQL. Port 1433 isn’t redirecting correctly for some reason, but I determined that it’s listening on 1434 by using the script below.

There was an issue with self signed certificates (ConnectionError: Failed to connect to (server name here) - self signed certificate) which was resolved by adding trustServerCertificate: true.

At this point it’s failing with ConnectionError: Login failed for user 'eptest'. I think this might be more on the node side rather than the database server, because I can connect to the MSSQL server using SSMS with the user’s credentials and the user can access the configured database. I browsed through various js files related to connections and the connection pool, and the mssql implementation in ueberdb2 specifically, but nothing jumped out at me.

I added a firewall exception, just in case that was the issue, as described here: https://docs.microsoft.com/en-us/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access?view=sql-server-ver15#BKMK_dynamic_ports

Any suggestions? Is there any way to turn on more verbose logging?

Settings.json snippet

  /*"dbType": "dirty",
  "dbSettings": {
    "filename": "var/dirty.db"
  },*/

  "dbType": "mssql",
  "dbSettings": {
    "user":     "eptest",
    "password": "user's password here",
    "host":     "localhost",
    "port":     1434,
    "database": "etherpad_lite_db",
    "options": {
        "trustServerCertificate": true
    }
  },

For future users, here’s the script to find the port that MSSQL is listening on:

USE master
GO
xp_readerrorlog 0, 1, N'Server is listening on' 
GO

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JohnMcLearcommented, Feb 17, 2021

I haven’t contributed to an open source project on Github before.

Well you are doing great 😃

If the changes require changes to source code or docs within the repository (README.md etc)then you would make a PR. If the docs are just within the wiki, they are editable without any peer review.

This item can be closed. I’m still working on windows in parallel to you btw, it is something we will fix in core that wont require any windows hackery.

1reaction
alexeisenhartcommented, Feb 17, 2021

@JohnMcLear I have Etherpad up and running on my Windows dev box using MSSQL! Below are my debugging notes, which will hopefully help someone else (or me!) in the future. Thank you again for your help!


I didn’t know this existed, but there are great SQL Server logs that might be useful to people who are diagnosing this issue. https://docs.microsoft.com/en-us/sql/relational-databases/performance/view-the-sql-server-error-log-sql-server-management-studio?view=sql-server-ver15

In my case, I’m seeing two errors for each login attempt:

Login failed for user 'eptest'. Reason: Login-based server access validation failed with an infrastructure error. Login lacks connect endpoint permission. [CLIENT: 127.0.0.1]

Error: 18456, Severity: 14, State: 149.

This lead me to: https://dba.stackexchange.com/questions/214374/login-lacks-connect-endpoint-permission-in-sql-server-error-18456-state-149

In SQL Server, run this. You should have at least one record returned. I have a record, so IDK what to do if you don’t, but that is something to look into.

SELECT * FROM sys.server_permissions AS sp2 
    JOIN sys.server_principals AS sp
        ON sp2.grantee_principal_id = sp.principal_id
    LEFT OUTER JOIN sys.endpoints AS e
        on sp2.major_id = e.endpoint_id
WHERE sp2.permission_name = 'CONNECT' 
AND sp2.class_desc = 'ENDPOINT'

-- Should be at least one record matching the following
AND sp2.state_desc = 'Grant' and sp.name = 'public' and e.name = 'TSQL Default TCP'

Following that, I granted CONNECT permissions for the TSQL Default TPC endpoint. First I granted to only this SQL user and then I granted to public; neither resolved the issue.

GRANT CONNECT ON ENDPOINT::[TSQL Default TCP] TO sptest;
GRANT CONNECT ON ENDPOINT::[TSQL Default TCP] TO public;

Maybe your TCP/IP connection is disabled. This was my problem. I have a default installation of developer edition of MSSQL that I just set up this week. I’ve been using SQL Server with ASP.NET, services, Winforms, WPF, etc for 15 years and I’ve never had reconfigure this. I believe that SSMS will usually connect with named pipes rather than a local TCP/IP connection, so testing the login credentials with SSMS was not a valid test.

Use the ‘SQL Server Configuration Manager’, go to the network configuration section and confirm that TCP/IP is enabled (enable it if you need to). Open the properties of TCP/IP and confirm that IP4 is active and take note of the configured Port.

After making these changes, I adjusted my connection configuration to use the correct and default port, 1433, and the SQL user was able to connect in both the MVP test and in etherpad.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A network-related or instance-specific error occurred - SQL ...
This error usually means that the client can't find the SQL Server instance. This issue occurs when at least one of the following...
Read more >
Error Cannot Connect to Server - A network-related or ...
Open "SQL Server Configuration Manager" · Now Click on "SQL Server Network Configuration" and Click on "Protocols for Name" · Right Click on...
Read more >
Resolving could not open a connection to SQL Server errors
Resolving could not open a connection to SQL Server errors · Step 1 - Check that you can ping the SQL Server box...
Read more >
Unable to connect to MSSQL database
The TCP/IP connection to the host on port 1433 has failed. Make sure that an instance of SQL Server is running on the...
Read more >
Unable to connect to SQL Server instance remotely
12 Answers 12 · Launch SQL Server Configuration Manager on your VPS. · Take a look at the SQL Server Network Configuration. Make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found