By Olayemi
I am trying to setup postgraphile on an already existing DigitalOcean hosted postgres db by following the instructions here https://www.graphile.org/postgraphile/quick-start-guide/ “npx postgraphile -c ‘postgres://user:secret-0.b.db.ondigitalocean.com:25060/defaultdb?sslmode=require?ssl=true&sslrootcert=ca-certificate.crt’ --watch --enhance-graphiql --dynamic-json” but it fails on the very first trial with a connection time out error reproduced below. PostGraphile v4.12.3 server listening on port 5000 :rocket:
‣ GraphQL API: http://localhost:5000/graphql ‣ GraphiQL GUI/IDE: http://localhost:5000/graphiql ‣ Postgres connection: postgres://doadmin:[SECRET]@user.b.db.ondigitalocean.com:25060/defaultdb (watching) ‣ Postgres schema(s): public ‣ Documentation: https://graphile.org/postgraphile/introduction/ ‣ Node.js version: v14.17.0 on linux x64 ‣ Join Simon Elliott in supporting PostGraphile development: https://graphile.org/sponsor/
A serious error occurred when building the initial schema. Exiting because retryOnInitFail is not set. Error details:
Error: connect ETIMEDOUT 46.101.73.34:25060 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
it seems like a permission issue of the server not allowing connections from the location.
How can I resolve this?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
I might be wrong, but this looks less like a PostGraphile issue and more like basic connectivity to the managed database.
On DigitalOcean Managed PostgreSQL, connections are restricted by default. If you try to connect from your local machine or another server that is not explicitly allowed, you’ll usually hit a timeout like this rather than an auth error.
A few things to check:
Make sure the database’s trusted sources include your current public IP, or run PostGraphile from a Droplet in the same region and VPC.
Verify you are using the correct port (25060) and that SSL is enabled. For managed databases, sslmode=require is mandatory.
Double check the connection string format. You should only have one ? and then use & for additional parameters.
In most cases, once the source IP is allowed (or the app runs from a Droplet inside the same region), the timeout goes away and PostGraphile connects normally.
Heya, @olayemi
That timeout usually isn’t PostGraphile-specific — it means your machine can’t reach the Managed Postgres endpoint/port at all.
First thing I’d check is the Managed DB “Trusted sources” / inbound allowlist in the DO control panel. If you’re running npx postgraphile … on your laptop, DO needs to allow your laptop’s public IP. If you only allow your Droplet/VPC, your local run will just ETIMEDOUT.
Also, your connection string formatting is a bit off: you can only have one? to start query params, then use & for the rest. For example:
postgres://user:pass@host:25060/defaultdb?sslmode=require
(and if you’re adding a root cert, it would be … ?sslmode=verify-full&sslrootcert=/path/to/ca.crt, not another ?).
If you don’t want to keep opening your home IP (or it changes), the practical approach is: run PostGraphile on a Droplet in the same region/VPC as the database, or SSH tunnel through a Droplet that is allowed, and connect PostGraphile to localhost through that tunnel.
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.