microsoft / microsoft/vscode-pgsql

Unable to connect to PostgreSQL db within Codespace, but works on Azure Data Studio

Open
#93 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
395
Forks
33
Avg merge
1h 46m
Merged PRs (30d)
3

Description

Background

  • I am able to connect to my PostgreSQL container running in Codespace via Azure Data Studio without issue.
  • Given Azure Data Studio is getting deprecated next year, I wanted to switch over as soon as possible.

Describe the bug

  • I am unable to connect when using this extension on VSCode.

To Reproduce

Steps to reproduce the behavior:

  1. Start a new codespace with .devcontainer --> docker-compose.yml file containing:
version: '3.8'

networks:
  localnet:
    driver: bridge


services:
  devcontainer:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ../..:/workspaces:cached
    command: sleep infinity
    networks:
      - localnet

  test-db:
    image: postgis/postgis:latest
    restart: unless-stopped
    volumes:
      - test-postgres-data:/var/lib/postgresql/data
    ports:
      - 5602:5432
    environment:
      POSTGRES_PASSWORD: pguser
      POSTGRES_USER: pguser
      POSTGRES_DB: test_db
    networks:
      - localnet

volumes:
  test-postgres-data:
  1. Start up Codespace and in terminal, confirm db container is running via docker ps. E.g.

Image

  1. Connect to db via Azure Data Studio and confirm connection works. E.g.
    • Connection Type: PostgreSQL
    • Server name: localhost
    • Authentication Type: Password
    • User name: pguser
    • Password: pguser
    • Database name: test_db
    • Advanced --> Host IP Address: 127.0.0.1
    • Advanced --> Port: 5602
  2. Attempt to connect to db via VSCode using Microsoft's PostgreSQL extension with settings:
    • Server Name: 127.0.0.1
    • Authentication Type: Password
    • User Name: pguser
    • Password: pguser
    • Database Name: test_db
    • Advanced --> Ports: 5602
    • Click "Test Connection"

Expected behavior

  • Connection successful

Actual behavior

  • Connection failed:

Image

^ NOTE: if Codespace setup was the issue, then Azure Data Studio should also fail, but it connects.

Sharing Code -> About Visual Studio Code (macOS) info:
Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the setup from .devcontainer/docker-compose.yml, using the listed PostgreSQL credentials and port 5602. Compare the successful Azure Data Studio connection with the VS Code extension's Test Connection failure, including the error shown in the report. Done means the extension connects successfully to test_db from the Codespace.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, postgresql, vscode
Domain
databases, developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.