Visual Studio Code Postgres SQL Connection
As per documentation here Npgsql has a Visual Studio extension (VSIX) which integrates PostgreSQL access into Visual Studio. It allows connecting to PostgreSQL from within Visual Studio's Server Explorer, create an Entity Framework 6 model from an existing database, etc. The extension can be installed directly from the Visual Studio Marketplace page.

The VSIX doesn't automatically add Npgsql to your GAC, App.config, machines.config or any other project or system-wide resource. It only allows accessing PostgreSQL from Visual Studio itself.

As here you van find out, How to Connect Visual Studio LightSwitch to PostgreSQL with dotConnect for PostgreSQL Data Provider.

As per postgresql documentation here  Could not translate host name localhost, service 5432 to address: nodename nor servname provided, or not known.

Usually this error is caused by broken /etc/hosts file. The problem could be a missing localhost entry, syntax errors or incorrect whitespace.

For reference, here is what this file should look like by default on macOS:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 


For further you ref here, here, here and here