Admin container can't connect to SQL

Hello !

I’m trying to install BitWarden on a CentOS 8 server but after what looked like a smooth installation I’m getting a 502 error from Nginx.

Using “docker ps” I can see that my admin and SSO containers are Unhealty. It seems that they can’t connect to the SQL server :

Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[3]
An exception was thrown attempting to execute the error handler.
System.Data.SqlClient.SqlException (0x80131904): 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: TCP Provider, error: 40 - Could not open a connection to SQL Server)

I have seen some post about similar problems on Synology’s NAS but I’m working on a CentOS 8 server. The CentOS is freshly install and have been update.

It’s the first time I’m using Docker and I can have missed something, like where this /home/runner/ folder can be…

Any help will be welcomed ! ^^

I just installed the latest on CentOS 8 and having the exact same issue, the admin and sso containers are unhealthy.

My error in bitwarden-admin log file:

System.Data.SqlClient.SqlException (0x80131904): 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: TCP Provider, error: 40 - Could not open a connection to SQL Server)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Bit.Migrator.DbMigrator.MigrateMsSqlDatabase(Boolean enableLogging, CancellationToken cancellationToken) in /home/runner/work/server/server/util/Migrator/DbMigrator.cs:line 41
at Bit.Admin.HostedServices.DatabaseMigrationHostedService.StartAsync(CancellationToken cancellationToken) in /home/runner/work/server/server/src/Admin/HostedServices/DatabaseMigrationHostedService.cs:line 40
ClientConnectionId:00000000-0000-0000-0000-000000000000
info: Bit.Migrator.DbMigrator[12482444]
Migrating database.

I fixed the issue by disabling firewalld

systemctl disable firewalld

Then reboot

This will open everything up to get it working and then you can revisit setting the firewall ports if you need to use the firewall.

Thank you @DomitianX , it was a part of my problem !

The other part was that I had changed the name of the database during the install script. This option seems to be broken.

which ports should be additionally opened on firewall??

jumping into this discussion I had a similar experience today: Installed Bitwarden on a current AlmaLinux 8.6 install (fresh install, nothing else).
The web interface just gave 502 errors, the admin container wasn’t able to connect to the mssql container.

Disabling firewalld completely “fixed” it, but I’d rather say “made it work”: I’m not comfortable disabling firewalld completely, and I’m sure there will be a smarter solution. I just haven’t found any reasoning, but have the slight idea in the back of my head that DNS resolution between the containers didn’t work?!

Any hints are appreciated!