This is an issue i am running into now and then. I want to connect to a local instance of MS SQL Server via 127.0.0.1 or localhost hostname and it just doesn't work. What you need to do is to activate TCP/IP connections in SQL Server Connection Manager.
Open C:\Windows\SysWOW64\SQLServerManager14.msc via WIN+R, that is for SQL Server 2017, you can see the names of other versions here.
Then go to SQL Server Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP and enable that.