Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Unhandled Exception. Microsoft.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.

Unhandled exception. Microsoft.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.

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

Profile picture for user tukur
By tukur , 16 March, 2023
Forums
Gurux.DLMS.AMI

Hello,
I pulled the AMI docker image and run docker run guruxorg/guruxdlmsamiserver. It showed:
Database type: MSSql
Connecting: Server=SQL_SERVER;Database=msdb;User ID=USER_ID;Password='USER_PASSWORD'

Then it failed with this error message below:
Unhandled exception. Microsoft.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.

What am I doing wrong.

Thanks

Profile picture for user Kurumi

Kurumi

3 years 2 months ago

Hi, You need to change SQL…

Hi,

You need to change SQL_SERVER to the name or TCP/IP address where your SQL server is.

You need to change also USER_ID and USER_PASSWORD to the correct values.

BR,
Mikko

Profile picture for user tukur

tukur

3 years 2 months ago

In reply to Hi, You need to change SQL… by Kurumi

Thanks for your response,…

Thanks for your response,
The reason why I ran 'docker run guruxorg/guruxdlmsamiserver' is because the instruction on https://hub.docker.com/r/guruxorg/guruxdlmsamiserver says you don't need to set up any database to test the system. so you can just run it and see it working before you may set external database later.

However, I also set up my xampp SQL database which runs locally on my PC at http://localhost/phpmyadmin I created a DB amr-project, user: root and without password. I generated the HTTPS certificate and then ran docker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=localhost;Database=amr-project;UID=root;Password=" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest

and I got this error:
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
---> System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)

Thanks in anticipation of your helpful response.

Profile picture for user Kurumi

Kurumi

3 years 2 months ago

In reply to Thanks for your response,… by tukur

Hi, I believe that you don't…

Hi,

I believe that you don't have MySQL installed on your PC.
You don't need to install the DB if you use SQLite. Chech this:

Run a container using SQLite in-memory database:

Get also the latest version. There are some user creation issues fixed.

BR,
Mikko

Profile picture for user tukur

tukur

3 years 2 months ago

Good day, I installed MySQL…

Good day,

I installed MySQL and still receiving some errors.

Then I installed sqlite3 and run it, this is what I got.

docker run --rm -it -e "Database:Type=SQLite" -e "Database:Settings=Filename=:memory:" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest
Database type: SQLite
Connecting: Filename=:memory:
Unhandled exception. System.ArgumentException: Data Source cannot be empty. Use :memory: to open an in-memory database
at System.Data.SQLite.SQLiteConnection.Open()
at Gurux.Service.Orm.GXDbConnection..ctor(DbConnection[] connections, String tablePrefix)
at Gurux.DLMS.AMI.Server.ServerSettings.ConnectToDb(WebApplicationBuilder builder) in /src/Gurux.DLMS.AMI/Server/ServerSettings.cs:line 618
at Program.<Main>$(String[] args) in /src/Gurux.DLMS.AMI/Server/Program.cs:line 53
at Program.<Main>(String[] args)

What am I doing wrong?

Profile picture for user Kurumi

Kurumi

3 years 2 months ago

In reply to Good day, I installed MySQL… by tukur

Hi, If you are using MySql…

Hi,

If you are using MySql your comman line argument are:

Where HOST is name of your PC where you did install MySQL.
DATABASE_SERVER is name of your database.

in Linux:

docker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=HOST;Database=DATABASE_SERVER;UID=USER_ID;Password=DATABASE_PASSWORD" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="YOUR_CREDENTIAL_PASSWORD" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v ${HOME}/.aspnet/https:/https/ guruxorg/guruxdlmsamiserver:latest

In Windows:
ocker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=HOST;Database=DATABASE_SERVER;UID=USER_ID;Password=DATABASE_PASSWORD" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="YOUR_CREDENTIAL_PASSWORD" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v %USERPROFILE%.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest

Let me know if you have problems.

BR,
Mikko

Profile picture for user tukur

tukur

3 years 2 months ago

Thanks for your response. I…

Thanks for your response.

I ran it as instructed but I still can't resolve it.

docker run --rm -it -e "Database:Type=MySQL" -e "Database:Settings=Server=DESKTOP-RM84GI7;Database=amr-project;UID=root;Password=12345" -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password="my_password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/Gurux.DLMS.AMI.Server.pfx -v $env:USERPROFILE\.aspnet\https:/https/ guruxorg/guruxdlmsamiserver:latest

Database type: MySQL
Connecting: Server=DESKTOP-RM84GI7;Database=amr-project;UID=root;Password=12345
Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch)
at System.Net.Dns.<>c.<GetHostEntryOrAddressesCoreAsync>b__33_0(Object s, ValueStopwatch stopwatch)

Profile picture for user tukur

tukur

3 years 2 months ago

I realized I was using my…

I realized I was using my wifi name instead of my PC name. Now that I've used the correct name, I'm getting a different error message.

Unhandled exception. MySql.Data.MySqlClient.MySqlException (0x80004005): Host 'host.docker.internal' is not allowed to connect to this MySQL server
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)

I tried it again, and it shows
Host 'tukur-desktop.mshome.net' is not allowed to connect to this MySQL server

Profile picture for user tukur

tukur

3 years 2 months ago

Problem Resolved! And I was…

Problem Resolved! And I was able to launch the App successfully.

For the benefit of new users:

The problem I got was a result of these:
1. I used my wifi-name instead of my PC name at Database: Settings=Server
2. I was using the default root user for MySQL which doesn't allow remote connection (Docker is also considered a remote connection). So I created a new user in MySQL who can access any IP address and used that for the database connection

and that was it.

Thanks for your time @Kurumi

Profile picture for user Kurumi

Kurumi

3 years 2 months ago

In reply to Problem Resolved! And I was… by tukur

Hi, Thank you very much for…

Hi,

Thank you very much for this information. Your attention from the root user is excellent. That is added to the documentation.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin