For me all the ideas of https://github.com/prisma/prisma/issues/4363 https://github.com/prisma/prisma/issues/2675 https://github.com/prisma/prisma/issues/4334 to fix it did not help out:
Maybe you have tips to me:
What I do to test is the following:
docker-compose.yml fileprisma deployyml (idea 1):
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
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: mongo
uri: 'mongodb://localhost:27017/admin'
yml (idea 2):
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
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: mongo
uri: >-
mongodb+srv://localhost:27017/mydb?fake=true
Prisma deploy:
prisma deploy
! Could not connect to server at http://localhost:4466. Please check if your server is running.
docker compose logs:
prisma_1 | Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
prisma_1 | at scala.sys.package$.error(package.scala:26)
prisma_1 | at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
prisma_1 | at com.prisma.local.PrismaLocalDependencies.(PrismaLocalDependencies.scala:48)
prisma_1 | at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
prisma_1 | at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
prisma_1 | at scala.Function0.apply$mcV$sp(Function0.scala:34)
prisma_1 | at scala.Function0.apply$mcV$sp$(Function0.scala:34)
prisma_1 | at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
prisma_1 | at scala.App.$anonfun$main$1$adapted(App.scala:76)
prisma_1 | at scala.collection.immutable.List.foreach(List.scala:388)
prisma_1 | at scala.App.main(App.scala:76)
prisma_1 | at scala.App.main$(App.scala:74)
prisma_1 | at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
prisma_1 | at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala)
Looks like the problem is with docker itself, not with prisma (so the issue wouldn't be with docker-compose but with the docker parent process). Can you try running docker logs --tail 50 --follow <id>, where id is your container id (you can get it by running docker ps)?
Since you mention you're on Windows, my intuition is that maybe your processor doesn't have virtualization enabled, causing the docker container to be stuck in a restart loop, but we'll have to see what your logs say.
Good idea! This is the log of the ymls (idea 1 and 2), the message is not changing here:
Exception in thread "main" java.lang.IllegalArgumentException: A connection string using the mongodb+srv protocol can notcontain a host name that specifies a port
at com.mongodb.ConnectionString.parseHosts(ConnectionString.java:892)
at com.mongodb.ConnectionString.(ConnectionString.java:324)
at com.prisma.deploy.connector.mongo.MongoInternalDatabaseDefs.(MongoInternalDatabaseDefs.scala:9)
at com.prisma.deploy.connector.mongo.MongoDeployConnector.internalDatabaseDefs$lzycompute(MongoDeployConnector.scala:14)
at com.prisma.deploy.connector.mongo.MongoDeployConnector.internalDatabaseDefs(MongoDeployConnector.scala:14)
at com.prisma.deploy.connector.mongo.MongoDeployConnector.mongoClient$lzycompute(MongoDeployConnector.scala:15)
at com.prisma.deploy.connector.mongo.MongoDeployConnector.mongoClient(MongoDeployConnector.scala:15)
at com.prisma.deploy.connector.mongo.MongoDeployConnector.internalDatabase$lzycompute(MongoDeployConnector.scala:16)
at com.prisma.deploy.connector.mongo.MongoDeployConnector.internalDatabase(MongoDeployConnector.scala:16)
at com.prisma.deploy.connector.mongo.MongoDeployConnector.(MongoDeployConnector.scala:18)
at com.prisma.connectors.utils.ConnectorLoader$.loadDeployConnector(ConnectorLoader.scala:39)
at com.prisma.local.PrismaLocalDependencies.deployConnector$lzycompute(PrismaLocalDependencies.scala:87)
at com.prisma.local.PrismaLocalDependencies.deployConnector(PrismaLocalDependencies.scala:87)
at com.prisma.local.PrismaLocalDependencies.(PrismaLocalDependencies.scala:94)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala)
and this
Ah, I see now! Try removing the +srv part from the connection string and see if that helps. I believe that including the +srv protocol will cause MongoDB to query the DNS for a record of the running mongodb instance and then bind to that port, so it won't accept a port argument in the string when using it. Equivalently, I think you could omit the port, and it should work as well (and if you change the mongodb port in the future, your connection string will still be valid!)
Ohh indeed. That looks way better. But now I get this error instead:
prisma deploy
Creating stage default for service default !
! 'ECONNRESET': request to http://localhost:4466/management failed, reason: socket hang up
Get in touch if you need help: https://slack.prisma.io
To get more detailed output, run $ export DEBUG="*"
with this log:
No log level set, defaulting to INFO.
[WARNING] Unsupported option 'fake' in the connection string 'mongodb://localhost:27017/mydb?fake=true'.
[WARNING] Unsupported option 'fake' in the connection string 'mongodb://localhost:27017/mydb?fake=true'.
[INFO] Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[INFO] Exception in monitor thread while connecting to server localhost:27017
Exception opening socket
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.internal.connection.AsynchronousSocketChannelStream$OpenCompletionHandler.failed(AsynchronousSocketChannelStream.java:272)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:128)
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishConnect(UnixAsynchronousSocketChannelImpl.java:252)
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:198)
at sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
at sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:293)
... 1 more
[INFO] Initializing workers...
[INFO] Obtaining exclusive agent lock...
[INFO] Obtaining exclusive agent lock... Successful.
[INFO] Successfully started 1 workers.
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@762d6c12 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
Server running on :4466
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@4dde3f54 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[Warning] Management authentication is disabled. Enable it in your Prisma config to secure your server.
Warning: Management API authentication is disabled. To protect your management server you should provide one (not both) of the environment variables 'CLUSTER_PUBLIC_KEY' (asymmetric, deprecated soon) or 'PRISMA_MANAGEMENT_API_JWT_SECRET' (symmetric JWT).
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@13bda76c from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@3d1a9b47 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@61edab7c from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] Fatal error during deployment worker initialization: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
at com.mongodb.internal.connection.BaseCluster.createTimeoutException(BaseCluster.java:401)
at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:309)
at com.mongodb.internal.connection.BaseCluster.access$800(BaseCluster.java:65)
at com.mongodb.internal.connection.BaseCluster$WaitQueueHandler.run(BaseCluster.java:482)
at java.lang.Thread.run(Thread.java:748)
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@3fcdba5b from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
No log level set, defaulting to INFO.
[WARNING] Unsupported option 'fake' in the connection string 'mongodb://localhost:27017/mydb?fake=true'.
[WARNING] Unsupported option 'fake' in the connection string 'mongodb://localhost:27017/mydb?fake=true'.
[INFO] Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[INFO] Exception in monitor thread while connecting to server localhost:27017
Exception opening socket
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.internal.connection.AsynchronousSocketChannelStream$OpenCompletionHandler.failed(AsynchronousSocketChannelStream.java:272)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:128)
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@593d93e7 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
Server running on :4466
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@19fa83fb from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@5560c67f from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@4fc21457 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
[INFO] Fatal error during deployment worker initialization: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
at com.mongodb.internal.connection.BaseCluster.createTimeoutException(BaseCluster.java:401)
at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:309)
at com.mongodb.internal.connection.BaseCluster.access$800(BaseCluster.java:65)
at com.mongodb.internal.connection.BaseCluster$WaitQueueHandler.run(BaseCluster.java:482)
at java.lang.Thread.run(Thread.java:748)
[INFO] No server chosen by com.mongodb.async.client.ClientSessionHelper$1@6e39b6f2 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]}. Waiting for 30000 ms before timing out
Wow thank you so much, this issue finally helped me https://github.com/prisma/prisma/issues/3880
I use now:
databases:
default:
connector: mongo
database: mydb
uri: >-
mongodb://host.docker.internal:27017/admin
Overall it was localhost to host.docker.internal that helped me.
All up and running now:
Creating stage default for service default √
Deploying servicedefaultto stagedefaultto serverlocal818msChanges:
User (Type)
- Created type
User- Created field
idof typeID!- Created field
firstnameof typeString!Applying changes 1.2s
Generating schema 58ms
Saving Prisma Client (JavaScript) at E:\dev\database\generated\prisma-client\Your Prisma endpoint is live:
HTTP: http://localhost:4466
WS: ws://localhost:4466You can view & edit your data here:
Prisma Admin: http://localhost:4466/_admin
Glad to see it's working now! Best of luck with your project :)
Most helpful comment
Ah, I see now! Try removing the
+srvpart from the connection string and see if that helps. I believe that including the+srvprotocol will cause MongoDB to query the DNS for a record of the runningmongodbinstance and then bind to that port, so it won't accept a port argument in the string when using it. Equivalently, I think you could omit the port, and it should work as well (and if you change themongodbport in the future, your connection string will still be valid!)