How do I connect a remote computer to my local SQLEXPRESS instance?

Michael Champenois 21 Reputation points
2022-11-24T04:10:48.053+00:00

When I try to connect from a remote computer, I get the following error:

'The connection to the host [ip address], named instance sqlexpress failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.'

I followed all 3 of those steps, creating inbound rules (opening the firewall) for UDP traffic to port 1434 and tcp traffic at port 1433, and running the sql server browser service. The same error came up still. I checked the default tcp port for my sql, and it came up as 1433.

I use windows and version 2018 of Microsoft SQL.

The jdbc string I use is:

jdbc:sqlserver://[ip address]\SQLEXPRESS;databaseName=[databaseName]

I couldn't see any more clues in the error I was getting for how to fix things.
Clues on what else I could be doing wrong?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,299 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,518 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,487 questions
Windows 10 Security
Windows 10 Security
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
2,836 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
{count} votes

Accepted answer
  1. Bjoern Peters 8,856 Reputation points
    2022-11-24T12:05:50.647+00:00

    Hi @Michael Champenois

    If you are running a SQL Server Express Edition, it has a different network protocol configuration than the other editions.
    https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/default-sql-server-network-protocol-configuration?view=sql-server-ver16#default-configuration

    263933-image.png

    You usually have to enable the TCP protocol first and then restart the DB engine.. but (if) you have already worked through the SQLServerCentral post that enables those protocols.
    So, maybe you check your configuration and maybe check your firewall... UDP 1434 is not the only port you need to open, you also have to open tcp/1433 (default port) => maybe change the dynamic port to a fixed port

    Additionally to the post from Yufeishao (and based on his link):
    SQL Server Express usually installs as "localhost\sqlexpress", so you have to insert the instanceName parameter into your connectionstring

    jdbc:sqlserver://localhost;encrypt=true;**instanceName=sqlexpress**;integratedSecurity=true;<more properties as required>;  
    

1 additional answer

Sort by: Most helpful
  1. YufeiShao-msft 7,081 Reputation points
    2022-11-24T06:57:49.217+00:00

    Hi @Michael Champenois ,

    If you can connect SQL SERVER by SSMS, in general, default instance of SQL Server uses port 1433, but you said you are using the named instance, please check your error log to see what port the instance is listening on and specify that in your JDBC connection string

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/80aa335c-eddd-4f65-86d5-4628372bec82/commicrosoftsqlserverjdbcsqlserverexception-the-connection-to-the-host-joe-62cb72961d9-named?forum=sqldataaccess

    Please try to the connect string, you can add username and password in the string:

    Connect to a named database on a remote server:

    jdbc:sqlserver://localhost;encrypt=true;databaseName=AdventureWorks;integratedSecurity=true;  
    

    Connect on the default port to the remote server:

    jdbc:sqlserver://localhost:1433;encrypt=true;databaseName=AdventureWorks;integratedSecurity=true;  
    

    Please check out this doc:
    Building the connection URL

    -------------

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.