Can't resolve hostname on Laravel

I am trying to connec to my neon instance by following the Laravel guide.

I am trying to use the whole url, and trying to cut it off with just the part that starts with ep, but it can’t translate the host address.

Hi,

Your connection settings should appear similar to the following:

DB_CONNECTION=pgsql
DB_HOST=ep-icy-sun-148107.us-east-2.aws.neon.tech
DB_PORT=5432
DB_DATABASE=neondb
DB_USERNAME=daniel
DB_PASSWORD=

Let me know if this works. Are you using the pgsql driver?

Hey Daniel.

Thanks for replying!

My ENV looks like this:

DB_CONNECTION=pgsql

DB_HOST=ep-mute-violet-838973.eu-central-1.aws.neon.tech/neondb

DB_PORT=5432

DB_DATABASE=neondb

DB_USERNAME=redacted

DB_PASSWORD=redacted

Should I omit the /neondb part?

And yes. I use the postgres driver for PHP 8.1

yes, please try removing the /neondb part from the DB_HOST. That’s the database name, which you provide already with DB_DATABASE.

Hey Daniel.

So, after doing so, I got this error.

SQLSTATE[08006] [7] ERROR: Endpoint ID is not specified. Either please upgrade the postgres client library (libpq) for SNI support or pass the endpoint ID (first part of the domain name) as a parameter: ‘?options=endpoint%3D’. See more at Connection errors - Neon Docs
ERROR: connection is insecure (try using sslmode=require)

I am not quite sure about what they mean with endpoint ID?
Also the last part confuses me a bit. I shouldn’t require SSL from localhost if i’m not mistaken?

This error is reported if your driver does not support Server Name Indication (SNI). You can read more about that here:

In a Neon hostname, such is this one: ep-mute-violet-838973.eu-central-1.aws.neon.tech, the “ep-mute-violet-838973” part is the endpoint ID.

Can you try updating your pgsql driver to see if that helps? Maybe you have an older version on your system?

1 Like

Facing the same error with laravel, the only approach that worked for us was specifying the endpoint id on the password field.

1 Like

Could you provide an example?
I think that I already tried that.

And thank you for guidance anyway, Daniel.
I appreciate it. :slight_smile:

Hi @Nefiron Sorry you having connection trouble. The workaround mentioned by @ogmusn would look something like this:

DB_CONNECTION=pgsql
DB_HOST=ep-mute-violet-838973.eu-central-1.aws.neon.tech/neondb
DB_PORT=5432
DB_DATABASE=neondb
DB_USERNAME=daniel
DB_PASSWORD= endpoint=ep-mute-violet-838973;<password>
1 Like

Finally got it to work!

I used the approach mentioned, but in DB_HOST i omitted /neondb as a part of the hostname.

Thank you for your help, both you and @ogmusn :grinning:

1 Like

Great. Thanks for letting us know. You’re right. The DB_HOST value should not have the “/neondb” part. It should just be:
DB_HOST=ep-mute-violet-838973.eu-central-1.aws.neon.tech