Restart SQL Server
If you get a 'Failed to connect to SQL Server Error 40' and it was working before, it is possible that SQL Server stopped running.
Restart the Server computer. SQL Server should start running again after a reboot. If you still get the error, do the following:
1) Go to 'All Programs' - 'Microsoft SQL Server' and open Open 'SQL Server Configuration Manager'.
2) Click on SQL Server Services in the Left Pane.
3) Right click on SQL Sever (SERRAM) and select 'Start'.
Note that depending on how SQL Server was installed, it is also possible that SERRAM will be using the default instance of MSSQLSERVER or SQLEXPRESS.
The 'failed to connect error 40' should now be gone.