question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Net.Sockets.SocketException (111): Connection refused

See original GitHub issue

The issue

I’m trying to run my migration scripts using dotnet ef database update... but keep getting System.Net.Sockets.SocketException (111) errors. Before you jump to conclusions, I am able to successfully connect to the remote database using psql psql -h <host> -p <port> -U <username> -W <password> <database>.

System.Net.Sockets.SocketException (111): Connection refused
   at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout) in C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:line 703
   at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) in C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:line 555
   at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) in C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:line 414

Further technical details

Npgsql version: 2.1.2 PostgreSQL version: 12 dotnet core version: 2.2.202 Operating system (remote): Windows Server 2012R2 Operating system (local): Ubuntu 18.04.4 LTS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
rojicommented, May 4, 2020

“Connection refused” means that a socket connection could not be established - Npgsql doesn’t do anything special here, just uses the standard networking APIs. In other words, this is almost surely some sort of environmental issue that’s unrelated to Npgsql - firewall, bad docker config, etc. As a first step it’s always good to try to connect with psql (or any other PostgreSQL client).

Am going to close this for now, because I don’t have any clear information about a problem in Npgsql.

0reactions
thebazshahcommented, May 4, 2020

I’m having the same issue. I also created separate network and tried to access the machines using their hostnames defined in docker-compose.yml. No luck. Getting exact same issue. System.Net.Sockets.SocketException (111): Connection refused

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Application startup exception: System.Net.Sockets. ...
"Application startup exception: System.Net.Sockets.SocketException (111): Connection refused" with docker-compose ; "3.7" networks: kitchen-table ...
Read more >
[Solved]-"Application startup exception: System.Net.Sockets ...
Coding example for the question "Application startup exception: System.Net.Sockets.SocketException (111): Connection refused" with docker-compose-docker.
Read more >
What is ConnectionRefusedError Errno 111 Connection ...
The ConnectionRefusedError errno 111 connection refused is a socket error that results when there is a failure in the establishment of ...
Read more >
Dotnet inside Docker giving Connection Refused error
Net.Sockets.SocketException (111): Connection refused digital-twin-api | at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 ...
Read more >
SSH session in browser (Kudu): An error occurred while ...
System.Net.Sockets.SocketException (111): Connection refused at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found