AppHarbor reports server was not found or was not accessible

41 Views Asked by At

On AppHarbor using the Yocto server add on, running EF6 I am able to write to the database (I'm able to log progress through to the homepage into the database), read from it as well, but when attempting to go to any page requiring authorization I get the dreaded

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I have one ContextDb defined and have it properly named (since I'm able to read from the database prior to logging in). I have Aliased the name in the AppHarbor Database settings (my logger which logs to the same database shows that indeed the connectionstring is properly injected). This application works perfectly locally on my dev machine.

One thing that is a little different is that the ApplicationUserManager is set to use my db context. I have added logging statements that prove that I'm actually completing all of the EF queries prior to the exception, and showing that the page is about to render. I have no idea which SQL query is causing the problem but the last one was:

SELECT 
    [Extent1].[Id] AS [Id], 
    [Extent1].[Title] AS [Title], 
    [Extent1].[Description] AS [Description], 
    [Extent1].[CreatedAt] AS [CreatedAt], 
    [Extent1].[UpdatedAt] AS [UpdatedAt]
    FROM [dbo].[Forum] AS [Extent1]

which appears to have executed correctly.

-- Executing asynchronously at 12/10/2017 11:28:54 PM +00:00
-- Completed in 1 ms with result: SqlDataReader

Closed connection at 12/10/2017 11:28:54 PM +00:00

I think this has something to do with the LoginManager, but as yet I have been unable to identify where it is attempting and failing to connect to the database.

1

There are 1 best solutions below

0
J Carroll On

Ok, I've found the solution to the problem. I'm surprised that AppHarbor doesn't have this posted in here somewhere (at least that I could find, based on the symptoms that I'm seeing) The solution to this problem is to run: aspnet_regsql.exe from dev command prompt. The key is to copy the database name from within the connectionstring displayed by appharbor. The server, userid, and password are all easily copied as they have their own fields. Anyway, my website is up and running again after a week of being down. Hopefully if anyone else has this issue this will help them.