I've tried to connect Prisma with postgreSQL several times. prisma show this error message : "Error: undefined: invalid port number in "postgresql://postgres:password@localhost:5432/linker")".
-error
-prisma/.env
DATABASE_URL=postgresql://postgres:password@localhost:5432/linker
-schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
So, first, I checked the port number to see if it was right and 5432 is right because I use the default port number. I also checked the postgresql.conf file, which is set to "listen_address="*"" , "port=5432".
And I went into pgAdmin4 and saw server's properties. the port number was 5432 as shown below image, and the username was set "postgres".
I don't know why prisma can't connect
Did i something missed?
Make sure that in your DATABASE_URL
in the .env
file, the special characters are replaced with percent-encodings.
For example, if your username or password contains @
character, it should be replaced with its equivalent percent-encoding, that is %40
. For #
it is %23
and so on. See the list below.
Following are the percent-encodings for the frequently used special characters:
Special Character | Percent Encoding |
---|---|
! |
%21 |
# |
%23 |
$ |
%24 |
% |
%25 |
& |
%26 |
' |
%27 |
( |
%28 |
) |
%29 |
* |
%2A |
+ |
%2B |
, |
%2C |
/ |
%2F |
: |
%3A |
; |
%3B |
= |
%3D |
? |
%3F |
@ |
%40 |
[ |
%5B |
] |
%5D |
newline |
%0A or %0D or %0D%0A
|
space |
%20 |
" |
%22 |
% |
%25 |
- |
%2D |
. |
%2E |
< |
%3C |
> |
%3E |
\ |
%5C |
^ |
%5E |
_ |
%5F |
` |
%60 |
{ |
%7B |
| |
%7C |
} |
%7D |
~ |
%7E |
£ |
%C2%A3 |
円 |
%E5%86%86 |
For anyone running into this, see the comments above on the answer!
Removing symbols from the db password (hosted on AWS RDS) fixed the problem for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With