Occasionally after building a new server and installing SQL Server you try to login to it and you receive this error:
A network-related or instance-specific error has occurred while establishing a connection to SQL Server.
Trying to connect using SQLCMD.
Trying to connect using SSMS.
First thing to do is open up SQL Server Configuration Manager on the server that has SQL Server installed. Look for SQL Server Network Configuration and then Protocols for MSSQLSERVER or whatever you instance is named. On the right pane, it shows TCP/IP is disabled.
We need to enable TCP/IP because that is the protocol we are using on our network to connect to the instance.
After making the change, we need to make sure we restart the following services: SQL Server (MSSQLSSERVER) (or your instance name) and SQL Server Browser (if you are using a named instance). You can do that by right clicking the name and selecting Restart.
After restarting the services, I can connect to the database using SQLCMD and run a query.
I can also connect using SSMS.
This is not the only solution for this connection error as it is a general error message, but it is the solution I find works most often. Other times it can be a firewall issue.
If you want to read more about SQLCMD, here is a link to the Microsoft documentation.