Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to fix the error "System.ArgumentException: Keyword not supported: 'port'." in net core?

I was trying to create two docker images: asp.net core and postgresq, but connection string doesnt recognize properly the port.

This is the docker-compose.yml file:

version: '3.4'


networks:
  -default:
    driver: bridge

services:
  netcoreapi:
    image: netcoreapi:latest
    depends_on:
      - "postgres_image"
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:80"
    networks:
        - default
    environment:
      netcoreapiContext: "host=postgres_image;port=5432;database=gr10_db;username=gr10;password=12345678"

  postgres_image:
    image: postgres:latest
    ports:
      - "5432"
    restart: always
    volumes:
      - db_volume:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: "gr10"
      POSTGRES_PASSWORD: "12345678"
      POSTGRES_DB: "gr10_db"
    networks:
       - default

volumes:
  db_volume:

and this is my appsettings.json :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"AllowedHosts": "*",
  "ConnectionStrings": {
     "netcoreapiContext": "Server=127.0.0.1; port=5432;Database=gr10_db;Username=gr10;Password=12345678"
  }

Nevertheless, when I test the database, it return me the following message:

System.ArgumentException: Keyword not supported: ‘port’. at Microsoft.Data.Common.DbConnectionOptions.ParseInternal(Dictionary2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)

if anyone could bring e some help, I’d be grateful

>Solution :

Try something like:

"netcoreapiContext":"Host=127.0.0.1;Port=5432;Database=gr10_db;Username=gr10;Password=12345678"

Some connection PostgreSQL connection strings examples can be found in Npgsql docs or here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading