How to specify a Port Number to Connect to SQL Server Instance

To specify the port when connecting to a SQL Server instance, use a comma to separate the server name or IP and the port.
For example:

ServerName,4321

Or you can use IP and the port number:

192.168.1.22,6789

For named instances, you usually connect by specifying the server name and instance name:

ServerName\InstanceName

If you specify the port that the named instance is using, there is no need to specify the instance name, because each instance on a server uses a different port:

ServerName,9876