title: Connection Refused error on Postgres database creation using Npgsql Entity Framework Core
body: <p>I am trying to create and use a PostgreSQL database with my .NET Core application. I'm using Entity Framework Core provided by Npgsql, and I'm going for the 'code-first' approach. However, when I try to generate the database (using either migrations or the "Database.EnsureCreated()" method) I always get the same error:</p>
  
  <p><strong>Npgsql.NpgsqlException (0x80004005): Exception while connecting
   ---> System.Net.Sockets.SocketException (10061): Connection refused.</strong></p>
  
  <p>I have tried both on Windows and Linux, and I've gotten the same result.</p>
  
  <p>The packages I've added for my project are:</p>
  
  <ul>
  <li><em>Npgsql.EntityFrameworkCore.PostgreSQL</em> version 3.1.3</li>
  <li><em>Microsoft.EntityFrameworkCore.Design</em> version 3.1.3</li>
  </ul>
  
  <p>My project uses .NET Core 3.1</p>
  
  <p>Here's my code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using Microsoft.EntityFrameworkCore;
  using System;
  
  namespace PostgresTest {
      class Program {
          static void Main(string[] args) {
              Console.WriteLine("Hello World!");
          }
      }
      public class PeopleContext : DbContext {
          public DbSet&lt;Person&gt; People { get; set; }
          protected override void OnConfiguring(DbContextOptionsBuilder options)
              =&gt; options.UseNpgsql("Host=localhost;Database=postgres;Port=5432;Username=postgres;Password=12345678");
      }
      public class Person {
          public int Id { get; set; }
          public string Name { get; set; }
          public int Age { get; set; }
      }
  }
  
  </code></pre>
  
  <p><strong>Edit</strong>: To be clear, when I use migrations, creating the migration itself succeeds, but I will still get the error mentioned above when I use the 'database update' command afterwards.</p>