2 years ago
I'm pretty new to all of this. I've tried for hours to find a solution. I really need help please.
node:internal/modules/cjs/loader:1143
throw err;
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
code: 'MODULE_NOT_FOUND',
}
Node.js v18.20.5
node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module '/app/mysqld'
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.20.5
Deploy crashed
``26 Replies
2 years ago
why do you have a mysql daemon in your NodeJS application?
If you're trying to use a MySQL database then you can just deploy one into your Railway project

I created a new project using my github repo (a5886754-0e45-4ccd-83df-a4b57ca5ecaa).
I added MySQL service. I try to copy the variables in my .env. Idk why the HOST is railway.internal instead of something that finishes with .railway.app
i already have a local database called "maville" that i'm trying to deploy
2 years ago
Please don't ping conductors
2 years ago
You are not. Can you please explain what you're trying to do? Are you trying to copy your service env variables into your local environment? If so, do not use the internal URL, you will need to use your database's public URL
I created a database and i read that i could use railway to deploy it and make it public. I thought i had to add my add my github repository and then add MySQL
2 years ago
You can, that's exactly what you have to do. Folow what Fragly said above, add a database to your project then copy the environment variables into your app
2 years ago
Make sure to reference the environment variables rather than commit the secrets to Github
is my .env correct?
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASSWORD=
MYSQL_DATABASE=maville
MYSQL_PORT=3306
PORT=8080
2 years ago
Looks fine to me, but only you can see your env variables
2 years ago
If they match, that's good
2 years ago
Actually, MYSQL_PORT should be the public URL port on your database. Make sure those match
2 years ago

2 years ago
Example from one of my services
2 years ago
Your public networking URL should be used locally, internal URL should be used internally
still doesn't work idk what i'm doing wrong. I copied the env variables from railway and added them in my .env. I get this :
pattyboi22@MacBookAir MaVilleAPI % node index.js
Serveur API démarré sur http://localhost:8080
Erreur de connexion à la base de données : Error: getaddrinfo ENOTFOUND mysql.railway.internal
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'mysql.railway.internal',
fatal: true
}
it works now i had to change the host to the public network one . The problem is i can't find my API public url
2 years ago
Your api won’t have one by default, you’ll have to generate one in the service settings
2 years ago
give this a read: https://docs.railway.com/quick-start
2 years ago
!s
Status changed to Solved adam • over 1 year ago