https://supertokens.com/ logo
#support-questions
Title
# support-questions
r

raoul97

11/02/2022, 2:27 AM
Hey! Wanted to check if there’s any documentation on using rds with supertokens?
r

rp

11/02/2022, 3:55 AM
Hey! It should be the same as connecting with PostgreSQL / mysql
See our docs for connecting with these databases
r

raoul97

11/02/2022, 6:50 AM
I see! We’ve implemented that already But we’re getting { serviceName: 'HIB', code: 'COM-0', message: 'INTERNAL_SERVER_ERROR', context: {}, originalError: Error: No SuperTokens core available to query at Querier. (/Users/raoulnandwani/AF-IAM/huat-iam-service-backend/node_modules/supertokens-node/lib/build/querier.js:225:27) at Generator.next () at /Users/raoulnandwani/AF-IAM/huat-iam-service-backend/node_modules/supertokens-node/lib/build/querier.js:30:75 at new Promise () at __awaiter (/Users/raoulnandwani/AF-IAM/huat-iam-service-backend/node_modules/supertokens-node/lib/build/querier.js:12:16) at Querier.sendRequestHelper (/Users/raoulnandwani/AF-IAM/huat-iam-service-backend/node_modules/supertokens-node/lib/build/querier.js:218:13) at Querier. (/Users/raoulnandwani/AF-IAM/huat-iam-service-backend/node_modules/supertokens-node/lib/build/querier.js:245:43) at Generator.throw () at rejected (/Users/raoulnandwani/AF-IAM/huat-iam-service-backend/node_modules/supertokens-node/lib/build/querier.js:22:44) at processTicksAndRejections (node:internal/process/task_queues:96:5), httpStatusCode: 500, endpointUrl: '/auth/signup', inputParams: { formFields: [ [Object], [Object] ] } } We have changed the super tokens connection urI to SUPERTOKENS_CONNECTION_URI="http://localhost:3567"
r

rp

11/02/2022, 6:51 AM
are you using docker for the node server?
r

raoul97

11/02/2022, 6:51 AM
Yup we are using docker
r

rp

11/02/2022, 6:51 AM
right. So localhost refers to inside the docker container
r

raoul97

11/02/2022, 6:51 AM
For both posingress and super tokens
Yup
r

rp

11/02/2022, 6:52 AM
so you need to give the IP or the service name of the supertokens container instead of using localhost
k

kamyab

11/02/2022, 6:52 AM
can you please try with
http://supertokens:3567
r

raoul97

11/02/2022, 6:52 AM
Sure I’ll try that
Getting this after the change Error: getaddrinfo ENOTFOUND supertokens at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'supertokens', config: { url: 'http://supertokens:3567/apiversion', method: 'get', headers: { Accept: 'application/json, text/plain, */*', 'api-key': 'S2P3dbAJXgV3gTWlUqaXCcTITwV6u6', 'User-Agent': 'axios/0.21.4' }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 0, adapter: [Function: httpAdapter], xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: [Function: validateStatus], transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, data: undefined },
r

rp

11/02/2022, 6:57 AM
are you using docker compose?
r

raoul97

11/02/2022, 6:57 AM
request: Writable { _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: true, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: false, errorEmitted: false, emitClose: true, autoDestroy: true, errored: null, closed: false, closeEmitted: false, [Symbol(kOnFinished)]: [] }, _events: [Object: null prototype] { response: [Function: handleResponse], error: [Function: handleRequestError] }, _eventsCount: 2, _maxListeners: undefined, _options: { maxRedirects: 21, maxBodyLength: 10485760, protocol: 'http:', path: '/apiversion', method: 'GET', headers: [Object], agent: undefined, agents: [Object], auth: undefined, hostname: 'supertokens', port: '3567', nativeProtocols: [Object], pathname: '/apiversion' }, _ended: true, _ending: true, _redirectCount: 0, _redirects: [], _requestBodyLength: 0, _requestBodyBuffers: [], _onNativeResponse: [Function (anonymous)], _currentRequest: ClientRequest { _events: [Object: null prototype], _eventsCount: 8, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: false, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true,
useChunkedEncodingByDefault: false, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: 0, _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: false, socket: [Socket], _header: 'GET /apiversion HTTP/1.1\r\n' + 'accept: application/json, text/plain, */*\r\n' + 'api-key: S2P3dbAJXgV3gTWlUqaXCcTITwV6u6\r\n' + 'user-agent: axios/0.21.4\r\n' + 'x-amzn-trace-id: Root=1-636213ff-727ff0a21f89f6f719b9f6e8;Parent=21f6fe4f0393d277;Sampled=1\r\n' + 'Host: supertokens:3567\r\n' + 'Connection: close\r\n' + '\r\n', _keepAliveTimeout: 0, _onPendingData: [Function: nop], agent: [Agent], socketPath: undefined, method: 'GET', maxHeaderSize: undefined, insecureHTTPParser: undefined, path: '/apiversion', _ended: false, res: null, aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, host: 'supertokens', protocol: 'http:', addListener: [Function (anonymous)],
on: [Function (anonymous)], once: [Function (anonymous)], prependListener: [Function (anonymous)], prependOnceListener: [Function (anonymous)], removeListener: [Function (anonymous)], off: [Function (anonymous)], removeAllListeners: [Function (anonymous)], _redirectable: [Circular *1], [Symbol(kCapture)]: false, [Symbol(kNeedDrain)]: false, [Symbol(corked)]: 0, [Symbol(kOutHeaders)]: [Object: null prototype], [Symbol(OtListeners)]: [Object: null prototype] }, _currentUrl: 'http://supertokens:3567/apiversion', [Symbol(kCapture)]: false }, response: undefined, isAxiosError: true, toJSON: [Function: toJSON] } { serviceName: 'HIB', code: 'ENOTFOUND', message: ' INTERNAL_SERVER_ERROR', context: {}, originalError: { message: 'getaddrinfo ENOTFOUND supertokens', name: 'Error', description: undefined, number: undefined, fileName: undefined, lineNumber: undefined, columnNumber: undefined, stack: 'Error: getaddrinfo ENOTFOUND supertokens\n' + ' at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)\n' + ' at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17)', config: { url: 'http://supertokens:3567/apiversion', method: 'get', headers: [Object], transformRequest: [Array], transformResponse: [Array], timeout: 0, adapter: [Function: httpAdapter], xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: [Function: validateStatus], transitional: [Object], data: undefined }, code: 'ENOTFOUND' }, httpStatusCode: 500, endpointUrl: '/auth/signin', inputParams: { formFields: [ [Object], [Object] ] } }
Sorry that’s the full long error
We’re not using docker compose
Actually I tried following this blog https://supertokens.com/blog/connect-supertokens-to-database And at the end it says to testing this way: Verify that it is setup correctly by querying the core service: curl http://localhost:3567/hello If you get back a Hello reply, the core setup is done! But it says connection refused
Should the port be supertokens:3567 as well?
r

rp

11/02/2022, 7:42 AM
hmm. Whats the docker run command you are using? And which OS?
r

raoul97

11/02/2022, 7:54 AM
I used this docker run -p 3567:3567 --network=host -e POSTGRESQL_CONNECTION_URI="postgresql://supertokens_user:somePassword@192.168.1.1:5432/supertokens" -d registry.supertokens.io/supertokens/supertokens-postgresql
OS is macos
r

rp

11/02/2022, 7:55 AM
can you remove
--network=host
and then try
if you visit localhost:3567/hello on your browser, what do you get?
r

raoul97

11/02/2022, 8:03 AM
This is what we get
k

kamyab

11/02/2022, 8:09 AM
docker run -p 3567:3567 -e POSTGRESQL_USER="root" -e POSTGRESQL_PASSWORD="root" -e POSTGRESQL_HOST="localhost" -e POSTGRESQL_PORT="5432" -e POSTGRESQL_DATABASE_NAME="supertokens" -d registry.supertokens.io/supertokens/supertokens-postgresql
try to run this
r

raoul97

11/02/2022, 8:14 AM
tried this as well
Trying again in a few seconds for 57.0 mins... 02 Nov 2022 08:14:32:840 +0000 | ERROR | pid: 58a9ed63-73b5-4880-a406-39c8ef0e8d80 | [main] thread | io.supertokens.storage.postgresql.HikariLoggingAppender.doAppend(HikariLoggingAppender.java:132) | SuperTokens - Exception during pool initialization. 02 Nov 2022 08:14:32:840 +0000 | INFO | pid: 58a9ed63-73b5-4880-a406-39c8ef0e8d80 | [main] thread | io.supertokens.storage.postgresql.ConnectionPool.initPool(ConnectionPool.java:154) | Trying again in a few seconds for 56.8 mins...
getting these errors
r

rp

11/02/2022, 8:14 AM
this means the db connection is not working
r

raoul97

11/02/2022, 8:15 AM
ah i see
hmm
r

rp

11/02/2022, 8:15 AM
are you sure you have provided the right password, username, port, host of the db?
r

raoul97

11/02/2022, 8:16 AM
yup it should be right
This is our database server
i can access the connected database as well
through pgAdmin
r

rp

11/02/2022, 8:28 AM
oh right. ok. so the problem is that you are giving the host as localhost
for the postgresql connection
localhost in docker points to inside the container
r

raoul97

11/02/2022, 8:28 AM
ah i see
r

rp

11/02/2022, 8:29 AM
and since you are running postgresql on a different container, it's not reachable
so give it the Ip of your machine instead, and make sure that postgresql is reachable via that IP
r

raoul97

11/02/2022, 8:32 AM
okay i'll try that
Trying to use this to create a container with both services
version: '3' services: db: image: 'postgres:latest' environment: POSTGRES_USER: root POSTGRES_PASSWORD: root POSTGRES_DB: supertokens ports: - 5432:5432 networks: - app_network restart: unless-stopped healthcheck: test: ['CMD', 'pg_isready -U supertokens_user'] interval: 5s timeout: 5s retries: 5 supertokens: image: registry.supertokens.io/supertokens/supertokens-postgresql depends_on: - db ports: - 3567:3567 environment: POSTGRESQL_CONNECTION_URI: 'postgresql://root:root@203.116.73.130:5432/supertokens' networks: - app_network restart: unless-stopped healthcheck: test: > bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e "GET /hello HTTP/1.1\r\nhost: 127.0.0.1:3567\r\nConnection: close\r\n\r\n" >&3 && cat <&3 | grep "Hello"' interval: 10s timeout: 5s retries: 5 networks: app_network: driver: bridge
still can't seem to connect for some reason
r

rp

11/02/2022, 9:08 AM
use
db
instead of
203.116.73.130
it would be good if you do some reading up on networking with docker
since all these issues are docker related an not supertokens related
r

raoul97

11/02/2022, 9:09 AM
yup! thanks for the help!