Prisma1: Prisma cannot run command "prisma deploy" because prisma in docker cannot run

Created on 12 Jul 2018  Â·  37Comments  Â·  Source: prisma/prisma1

Describe the bug

I created a project in Prisma through prisma init and then introspected an existing PostgreSQL database from my local directory. What is left for me to be able to start my development is to run the command docker-compose up -d and then type prisma deploy, but then I realized that the docker container for my prisma image won't run with this error:

```prisma_1    | Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
prisma_1    |   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:245)
prisma_1    |   at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
prisma_1    |   at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
prisma_1    |   at org.postgresql.Driver.makeConnection(Driver.java:452)
prisma_1    |   at org.postgresql.Driver.connect(Driver.java:254)
prisma_1    |   at slick.jdbc.DriverDataSource.getConnection(DriverDataSource.scala:101)
prisma_1    |   at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:341)
prisma_1    |   at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:193)
prisma_1    |   at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:430)
prisma_1    |   at com.zaxxer.hikari.pool.HikariPool.access$500(HikariPool.java:64)
prisma_1    |   at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:570)
prisma_1    |   at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:563)
prisma_1    |   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
prisma_1    |   ... 3 more
prisma_1    | Caused by: java.net.ConnectException: Connection refused (Connection refused)
prisma_1    |   at java.net.PlainSocketImpl.socketConnect(Native Method)
prisma_1    |   at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
prisma_1    |   at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
prisma_1    |   at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
prisma_1    |   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
prisma_1    |   at java.net.Socket.connect(Socket.java:589)
prisma_1    |   at org.postgresql.core.PGStream.<init>(PGStream.java:69)
prisma_1    |   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:156)
prisma_1    |   ... 15 more```

_Note: my project runs on a Mac but not on my Windows laptop. I have the assumption that it's because I am using Docker Toolbox and I cannot install Docker for Windows since I'm using Windows 10 Home._

To Reproduce

Files
_docker-compose.yml_:
```version: '3'
services:
prisma:
image: prismagraphql/prisma:1.17
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: postgres
host: localhost
port: 5432
database: devjdbrc
schema: public
user: postgres
password: root
migrations: false

_datamodel.graphql:_

type Cartlab @pgTable(name: "Cartlab") {
asOf: DateTime!
createdAt: DateTime!
gradeLevel: Int
id: ID! @unique
itemRemarks: String
location: String!
specs: String
type: String!
updatedAt: DateTime!
Creserves: [Creserve!]!
}

type Creserve @pgTable(name: "Creserve") {
cartlab: Cartlab @pgRelation(column: "cartlabId")
createdAt: DateTime!
currentStatus: String @default(value: "reserved")
grade: Int!
id: ID! @unique
rDateEnd: DateTime!
rDateStart: DateTime!
section: String!
timezone: String!
updatedAt: DateTime!
user: User @pgRelation(column: "userId")
Reports: [Report!]!
}

type Report @pgTable(name: "Report") {
createdAt: DateTime!
creserve: Creserve @pgRelation(column: "creserveId")
id: ID! @unique
status: String
updatedAt: DateTime!
}

type User @pgTable(name: "User") {
createdAt: DateTime!
department: String!
firstName: String
id: ID! @unique
lastName: String
password: String!
subject: String!
updatedAt: DateTime!
userType: String
username: String!
Creserves: [Creserve!]!
}
```

_prisma.yml:_
endpoint: http://localhost:4466 datamodel: datamodel.graphql

Steps to reproduce the behavior: (EDITED AS OF 10/4/2018)

  1. Follow prisma docs until step 5 (link here)
    image
  2. get the docker-compose.yml from the files section above
  3. docker-compose up (it will output the error written above)
    image

Expected behavior

  1. The endpoint (localhost:4466) should be running after typingdocker-compose up -d
  2. No errors in running prisma deploy
  3. Can already access the URL of the endpoint in any browser to run GraphQL Playground

Screenshots
https://snag.gy/QRYw2P.jpg
^^ error in running prisma deploy

UPDATE:
prisma image runs but still encountering the same error screencapped above:
https://snag.gy/glq0eX.jpg

docker ps:
https://snag.gy/Xw541b.jpg

logs:
https://snag.gy/1yu9Cb.jpg

Versions (please complete the following information):

  1. Windows 10 Home
  2. Docker Toolbox latest version
    image
  3. Node version 10.4
  4. PostgreSQL 10.1
  5. Prisma 1.17.1

EDIT: will upload node backend server to my Github so that if you test introspecting the existing database that I have in my system, you can try it if it works (or replicate the error). Thanks!

bu0-needs-info

Most helpful comment

This happened to me when using Docker Toolbox on Windows 10, the endpoint had to be changed from using localhost to the VirtualBox default ip within prisma.yml:

endpoint: http://192.168.99.100:4466

All 37 comments

I have the same problem. At least I think I have...

I used prisma init and used an existing postgresql db.
Then docker-compose up

...
prisma_1  | Jul 15, 2018 7:36:49 PM org.postgresql.Driver connect
prisma_1  | SEVERE: Connection error: 
prisma_1  | org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
prisma_1  |     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:245)
prisma_1  |     at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
prisma_1  |     at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
prisma_1  |     at org.postgresql.Driver.makeConnection(Driver.java:452)
prisma_1  |     at org.postgresql.Driver.connect(Driver.java:254)
prisma_1  |     at slick.jdbc.DriverDataSource.getConnection(DriverDataSource.scala:101)
prisma_1  |     at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:341)
prisma_1  |     at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:193)
prisma_1  |     at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:430)
prisma_1  |     at com.zaxxer.hikari.pool.HikariPool.access$500(HikariPool.java:64)
prisma_1  |     at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:570)
prisma_1  |     at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:563)
prisma_1  |     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
prisma_1  |     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
prisma_1  |     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
prisma_1  |     at java.lang.Thread.run(Thread.java:748)
prisma_1  | Caused by: java.net.ConnectException: Connection refused (Connection refused)
prisma_1  |     at java.net.PlainSocketImpl.socketConnect(Native Method)
prisma_1  |     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
prisma_1  |     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
prisma_1  |     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
prisma_1  |     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
prisma_1  |     at java.net.Socket.connect(Socket.java:589)
prisma_1  |     at org.postgresql.core.PGStream.<init>(PGStream.java:69)
prisma_1  |     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:156)
prisma_1  |     ... 15 more

With

  • mac OS HighSierra 10.13.4
  • node 9.5.0
  • postgresql 10.3
  • prisma 1.11.1
  • docker 18.03.1-ce
  • docker-compose 1.21.1

Are you also using Docker Toolbox? Or is this Docker for Mac?

And do we have almost the same docker-compose.yml file?

Well I am using docker for mac. And my docker-compose.yaml looks like:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.11
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: localhost
            port: '5432'
            database: movies
            schema: public
            user: movies
            password: movies
            migrations: false

I've had a lot of issues referencing localhost on Windows when it's running from Docker (Docker-Toolbox). Doesn't seem like the bridge binds to the loopback.

Sorry for the late reply, I almost forgot this because work has been tough in the past week.

I'm currently doing my research on how to do this and will get back to you if it still does not work. Thank you!

I've just upgraded Prisma to prisma/1.12.0 (darwin-x64) node-v9.5.0, created whole schema from existing pg db again, and the result is still the same.

I might have missed something, but I think it really has to do with adding the docker-machine ip into your etc/hosts file or adding it into your pg_hba.conf file. It still doesn't work with me though.

I had the same issue, couldn't connect to my local postgresql DB until I added listen_addresses = '*' in my /usr/local/var/postgres/postgresql.conf then put my machine's IP in docker-compose.yml. See https://stackoverflow.com/a/13134525

Anyone able to resolve this?

Nope, I think my comment didn't save. But I tried this and it didn't work at least for me. Have you tried the latest suggestion?

I didn't have time for that yet :(

I do get same issue. @MortalFlesh Any updates on the issue ?

I'm super busy these days and I do this as my little free-time project, which I unfortunately dont have time atm. So no updates on my side :(

This happened to me when using Docker Toolbox on Windows 10, the endpoint had to be changed from using localhost to the VirtualBox default ip within prisma.yml:

endpoint: http://192.168.99.100:4466

I cannot reproduce this on my machine. Does someone have a step by step guide for the reproduction, so we can start looking into this issue?

Hey, sorry I wasn't able to go look back into this anymore. I will try to reproduce this behavior again based on what I wrote above and give a more detailed version of it.

@marktani edited the post. What I just did was to follow current prisma docs until step 5, added the docker-compose.yml written above with the credentials I have then ran docker-compose up in my machine. The error still persists up to now, as seen in the screenshot.

Let me know if you have any questions on replicating the error. I'll upload the node backend server if you to test introspecting my existing database but for now, this is how I replicated the error on my end. I hope I was able to clarify things. Thanks!

Can you share the specific link of the resource you followed until step 5?
Your initial post contains an individual docker-compose.yml, that is not used in our docs. Can you reproduce this with another docker-compose.yml as well?

Added the link in the post.

You mean reproduce it with a docker-compose.yml that is patterned from Prisma docs? What do you mean reproducing it with another docker-compose.yml?

Aha, I can now reproduce this, and I also found a workaround. I'm lacking fundamental understanding of Docker to fully understand what's going on.

Here is how I can reproduce this. In two separate directories, I run the following two docker-compose.yml files using docker-compose up -d:

First, the database:

version: '3'
services:
  postgres:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: prisma
      POSTGRES_PASSWORD: prisma
    ports:
      - "5432:5432"
    volumes:
      - postgres:/var/lib/postgresql/data
volumes:
  postgres:

Note that I used ports: - "5432:5432" to make the database available on the host machine via port 5432.

Here is the non-working docker-compose.yml for my Prisma server:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.17
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        databases:
          default:
            connector: postgres
            host: localhost
            port: 5432
            database: prisma
            schema: default$default
            user: prisma
            password: prisma
            migrations: false
            ssl: false

With these two files, I get the same behaviour as you described in your initial post.

If I use this working docker-compose.yml file, it works!

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.17
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        databases:
          default:
            connector: postgres
-           host: localhost
+           host: host.docker.internal
            port: 5432
            database: prisma
            schema: default$default
            user: prisma
            password: prisma
            migrations: false
            ssl: false

I am not sure if this is an issue we can resolve in Prisma, this feels like a configuration issue of Docker.

For windows, should I still use localhost? host.docker.internal isn't working either.

Can you try to use host.docker.internal instead of localhost?

This is a pure docker configuration issue and not Prisma related. If you're forced to use Docker Toolbox then you likely have to hard code the underlying VM IP to make it work or similar workarounds (not sure as I don't use Toolbox). As of Docker 18.03 onwards you're able to use host.docker.internal (DO NOT use the platform specifics like docker.for.mac.localhost, they have been dropped.).

Awesome, thanks for chiming in @dpetrick! I'll close this as it's beyond the scope of Prisma.
I've seen many discussions about this here: https://stackoverflow.com/search?q=host.docker.internal.

Yup it doesn't work, but it gives off a different error.

Thanks for helping!

@yaacovCR Good catch! It works!

I can confirm that @yaacovCR solution works for me on windows with Docker ToolBox

I have the same issue but using an external non-localhost database. So I can't use @marktani fix

to be able to deploy to prisma you need two server. a prisma server and a connector to postgres. the connector is also a server. so you can install pgadmin as connector and prisma can use it to connect to database.

This happened to me when using Docker Toolbox on Windows 10, the endpoint had to be changed from using localhost to the VirtualBox default ip within prisma.yml:

endpoint: http://192.168.99.100:4466

This works. Thanks a lot.

I just got it fixed by changing in the prisma.yml file from
endpoint: http://localhost:4466

to
endpoint: http://<MyMacIPAddress>:4466

And set in docker-compose.yml
ssl: false

I just got it fixed by changing in the prisma.yml file from
endpoint: http://localhost:4466

to
endpoint: http://<MyMacIPAddress>:4466

And set in docker-compose.yml
ssl: false

Im using windows 10 and Docker Toolbox. Putting docker machine ip in endpoint and removing ssl attribute solve the CONNECT error for prisma deploy. I was struggling for past 2 days. Thanx a lot @theodorenguyen45

Any idea on how to resolve it in Ubuntu?
My server doesn't start with
docker-compose up
It shows some java commands as shown up
Plz Help

@kaousheik : Could you please share complete stacktrace. What error you are getting on docker-compose up. Try deleting & removing previous containers and images associated with your project and start making fresh one.

Any idea on how to resolve it in Ubuntu?
My server doesn't start with
docker-compose up
It shows some java commands as shown up
Plz Help

I'm struggling to resolve this on a linux box as well. When I try changing the endpoint from localhost to my local IP (192.blah.blah.blah), I no longer get the error about checking to make sure the server is running, but instead I get an error like this:

Creating stage default for service default !
 â–¸    'ECONNREFUSED': request to http://192.168.4.245:4466/management failed, reason: connect ECONNREFUSED 192.168.4.245:4466

I'm using the prisma 1.34 docker image with a mysql database.

This was found in my logs:

java.sql.SQLException: Could not connect: Access denied for user 'root'@'172.18.0.3' (using password: YES)

@eldieco : Hi, I think you are getting above error while doing prisma deploy. Try using command prisma deploy -n. Choose ' Use other server ' option.

@eldieco : Hi, I think you are getting above error while doing prisma deploy. Try using command prisma deploy -n. Choose ' Use other server ' option.

I thought that was for deploying from your local machine to a remote server? What I’m trying to do is set up my remote sever so that I can start pushing code to it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marktani picture marktani  Â·  44Comments

marktani picture marktani  Â·  48Comments

marktani picture marktani  Â·  62Comments

sapkra picture sapkra  Â·  40Comments

blocka picture blocka  Â·  74Comments