Creating with existed data occurred error



postgres (PostgreSQL) 10.4
prisma/1.8.3 (darwin-x64) node-v8.11.2
Docker version 18.03.1-ce, build 9ee9f40

The error shows when using the local postgresql database.

FetchError: request to http://localhost:4466/management failed, reason: socket hang up
at ClientRequest. (/usr/local/lib/node_modules/prisma/node_modules/node-fetch/lib/index.js:1376:11)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketOnEnd (_http_client.js:423:9)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
Exiting with code: 1


Can you share your docker-compose.yml file?

version: '3'
    image: prismagraphql/prisma:1.8
    restart: always
    - "4466:4466"
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
            connector: postgres
            port: '5432'
            database: water_test
            schema: public
            user: username
            password: nibuzhidao
            migrations: false


What information does docker logs -f <prisma container id> reveal?
You can find out <prisma container id> by running docker ps.


docker ps

CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                    NAMES
5bd799fc4516        prismagraphql/prisma:1.8   "/bin/sh -c /app/sta…"   2 weeks ago         Up 9 seconds>4466/tcp   test6_prisma_1
50684e3f739f        prismagraphql/prisma:1.8   "/bin/sh -c /app/sta…"   2 weeks ago         Up 12 days>4465/tcp   test5_prisma_1
bd0cf45fbf21        postgres                   "docker-entrypoint.s…"   2 weeks ago         Up 12 days          5432/tcp                 test5_postgres_1

docker logs 5bd799fc4516

exception in thread "main" java.sql.SQLTransientConnectionException: database - Connection is not available, request timed out after 5001ms.
	at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(
	at com.zaxxer.hikari.pool.HikariPool.getConnection(
	at com.zaxxer.hikari.pool.HikariPool.getConnection(
	at com.zaxxer.hikari.HikariDataSource.getConnection(
	at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:18)
	at slick.jdbc.JdbcBackend$BaseSession.<init>(JdbcBackend.scala:439)
	at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:47)
	at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:38)
	at slick.basic.BasicBackend$DatabaseDef.acquireSession(BasicBackend.scala:218)
	at slick.basic.BasicBackend$DatabaseDef.acquireSession$(BasicBackend.scala:217)
	at slick.jdbc.JdbcBackend$DatabaseDef.acquireSession(JdbcBackend.scala:38)
	at slick.basic.BasicBackend$DatabaseDef$$anon$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$
Caused by: org.postgresql.util.PSQLException: Connection to refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Seems prisma is not able to connect the database.

My local database is able to connect.

Ted:tedzhang$ psql -d water_test -p 5432 -U tedzhang -W
Password for user tedzhang:
psql (10.4)
Type "help" for help.


Prisma cannot prisma deploy on Docker Toolbox

Change the host to:
host: host.docker.internal
in your docker-compose.


More information on this here: