'Error connecting server to DigitalOcean Postgresql droplet

I am aware that I can connect to a pre-configured Digital Ocean PostgreSQL database cluster and that's what I'm actually connected to right now, but I'd like to connect to a droplet instead (It's cheaper). The droplet is running Ubuntu and came set up with Node JS, PM2, and Nginx. I have already Installed postgreSQL and set up a database on it.

I try to connect to the droplet with this connection string:

DATABASE_URL="postgresql://<USERNAME>:<PASSWORD>@<DROPLET-IP-ADDRESS>:5432/<DBNAME>?schema=public"

and this is the error im getting:

Can't reach database server at `<DROPLET-IP-ADDRESS>`:`5432`\n\nPlease make sure your database server is running at `<DROPLET-IP-ADDRESS>`:`5432`.",

Whats the correct way of connecting via Prisma to a DigitalOcean droplet



Solution 1:[1]

If you changed listen_addresses to *, but forgotten to remove the comment (#) at the beginning of the line, the parameter will still be at its default value localhost. Check that the # is removed and restart PostgreSQL. Quite common mistake.

Also answered here by someone.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BirukTes