--- title: "Creating a Valid Connection String Using Named Pipes | Microsoft Docs" ms.custom: "" ms.date: "06/13/2017" ms.prod: "sql-server-2014" ms.reviewer: "" ms.technology: configuration ms.topic: conceptual helpviewer_keywords: - "connection strings [Database Engine], named pipes" - "pipes [SQL Server]" - "pipes [SQL Server], connecting to" - "aliases [SQL Server], named pipes" - "Named Pipes [SQL Server], connection strings" ms.assetid: 90930ff2-143b-4651-8ae3-297103600e4f author: craigg-msft ms.author: craigg manager: craigg --- # Creating a Valid Connection String Using Named Pipes Unless changed by the user, when the default instance of [!INCLUDE[msCoName](../../includes/msconame-md.md)] [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] listens on the named pipes protocol, it uses `\\.\pipe\sql\query` as the pipe name. The period indicates that the computer is the local computer, `pipe` indicates that the connection is a named pipe, and `sql\query` is the name of the pipe. To connect to the default pipe, the alias must have `\\\pipe\sql\query` as the pipe name. If [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] has been configured to listen on a different pipe, the pipe name must use that pipe. For instance, if [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is using `\\.\pipe\unit\app` as the pipe, the alias must use `\\\pipe\unit\app` as the pipe name. To create a valid pipe name, you must: - Specify an **Alias Name**. - Select **Named Pipes** as the **Protocol**. - Enter the **Pipe Name**. Alternatively, you can leave **Pipe Name** blank and [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Configuration Manager will complete the appropriate pipe name after you specify the **Protocol** and **Server** - Specify a **Server**. For a named instance you can provide a server name and instance name. At the time of connection, the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Native Client component reads the server, protocol, and pipe name values from the registry for the specified alias name, and creates a pipe name in the format `np:\\\pipe\` or `np:\\\pipe\`.For a named instance, the default pipe name is `\\\pipe\MSSQL$\sql\query`. > [!NOTE] > The [!INCLUDE[msCoName](../../includes/msconame-md.md)] Windows Firewall closes port 445 by default. Because [!INCLUDE[msCoName](../../includes/msconame-md.md)][!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] communicates over port 445, you must reopen the port if [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is configured to listen for incoming client connections using named pipes. For information on configuring a firewall, see "How to: Configure a Firewall for SQL Server Access" in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Books Online or review your firewall documentation. ## Connecting to the Local Server When connecting to [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] running on the same computer as the client, you can use `(local)`as the server name. Using `(local)` is not encouraged because it leads to ambiguity; however it can be useful when the client is known to be running on the intended computer. For instance, when creating an application for mobile disconnected users, such as a sales force, where [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] will run on laptop computers and store project data, a client connecting to (local) would always connect to the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] running on the laptop. The word `localhost` or a period (.) can be used in place of `(local)`. ## Verifying Your Connection Protocol The following query will return the protocol used for the current connection. ``` SELECT net_transport FROM sys.dm_exec_connections WHERE session_id = @@SPID; ``` ## Examples Connecting by server name to the default pipe: ``` Alias Name Pipe Name Protocol Named Pipes Server ``` Connecting by IP Address to the default pipe: ``` Alias Name Pipe Name Protocol Named Pipes Server ``` Connecting by server name to a non-default pipe: ``` Alias Name Pipe Name \\\pipe\unit\app Protocol Named Pipes Server ``` Connecting by server name to a named instance: ``` Alias Name Pipe Name \\\pipe\MSSQL$\SQL\query Protocol Named Pipes Server ``` Connecting to the local computer using `localhost`: ``` Alias Name Pipe Name Protocol Named Pipes Server localhost ``` Connecting to the local computer using a period: ``` Alias Name Pipe Name Protocol Named Pipes Server . ``` > [!NOTE] > To specify the network protocol as a **sqlcmd** parameter, see "How to: Connect to the Database Engine Using sqlcmd.exe" in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Books Online. ## See Also [Creating a Valid Connection String Using Shared Memory Protocol](../../../2014/tools/configuration-manager/creating-a-valid-connection-string-using-shared-memory-protocol.md) [Creating a Valid Connection String Using TCP IP](../../../2014/tools/configuration-manager/creating-a-valid-connection-string-using-tcp-ip.md) [Choosing a Network Protocol](../../../2014/tools/configuration-manager/choosing-a-network-protocol.md)