Today I went to connect to my local database but I cannot connect anymore for unknown reasons. I typed in (local) and used Windows authentication like I always do yet I get this error.
Cannot connect to localhost.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)
I just experienced the same problem. My database is stored on an external hard disk, unfortunately I plugged it in after I started the computer.
I had to restart the computer, to connect again successfully. A logout was not enough.
Is the SQL Server service running? To check, right-click on "My Computer" and choose "Manage..." From the tree on the left side of the window, choose "Services and Applications", then "Services". Look for the "SQL Server" service and see if it is in the "Started" status. If not, right-click on the service and choose "Start".
You may also want to check that the service is set to automatic start. this way when you reboot, you won't have to start the service...