2 years ago
Hi my site uses sqlite3 for the database and has been working fine. I just finished a new update and committed the changes to the GitHub repo my railway app is connected to but it crashed with this error: /node_sqlite3.node: invalid ELF header. I looked it up and it apperently its because i built the package on my local machine so it isnt working for the host machine. I don't know how i could build it on the host though so please help.
0 Replies
2 years ago
are you commiting your node_modules to github?
are you storing your sqlite file in a railway volume?
2 years ago
you don't want either to be in github
2 years ago
remove both from GitHub and then add them to the .gitignore, then change your code to store the sqlite database in a volume
2 years ago
but honestly it would likely be far easier if you used postgres
2 years ago
yes of course, you'd pay for it's cpu, memory, and disk
2 years ago
that's only going to cause headaches unless setup properly
ok i need to go for now but would you be able to help me set it up some other time?
2 years ago
like I said, I would highly recommend you use postgres
2 years ago
may i ask why?
2 years ago
interesting answer, it's definitely not simpler, and for this use-case you also definitely don't need access to the machine
I find it easier to build packages and setup the project through a command line
2 years ago
on railway you simply push to github, there's no setup besides adding environment variables
2 years ago
its done automatically
2 years ago
are you still including your node_modules folder and sqlite file in github?
2 years ago
that doesnt remove things from the repo
2 years ago
yes
2 years ago
if you arent going to use postgres, make sure your code stores the sqlite file in a volume
2 years ago
if you dont store the sqlite file in a volume the data in the sqlite file will not persist between deployments
2 years ago
you connect to postgres and use that instead of sqlite
2 years ago
you dont have to figure out how volumes works 🤣
2 years ago
with postgres? it's not exactly 1:1 compatible
2 years ago
don't overthink, you deploy postgres and then have your code connect to it
2 years ago
yeah add postgres to the project
2 years ago
that's not quite a railway specific question, and you would definitely be far better off watching a YouTube video for that, a YouTube video could do a much better explanation than me
2 years ago
haha thank you
Ok i have modified my code to work with postgres. Where do i find the connection string?
2 years ago
you dont necessarily need to find it, you need to reference it, on your apps service you would set the following service variable -
DATABASE_URL=${{Postgres.DATABASE_URL}}and then you use the DATABASE_URL environment variable in your code
ok i found it but im trying to connect to it from my local pc but its not letting me
2 years ago
what do you mean not letting you
Error: connect ECONNREFUSED 127.0.0.1:5432
at createConnectionError (node:net:1634:14)
at afterConnectMultiple (node:net:1664:40) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}
2 years ago
that says 127.0.0.1
2 years ago
i can assure you that you are not running railway locally
2 years ago
you need to connect to postgres on railway
2 years ago
and you need to connect to it
const db = new Client({
connectionString: asfasfasf,
ssl: {
rejectUnauthorized: false,
},
});
db.connect()
2 years ago
bruh
2 years ago
asfasfasf ???
2 years ago
let me know when this is done
2 years ago
I don't think I can continue helping if you aren't willing to follow along with my help
2 years ago
it was just adding a variable
2 years ago
no, I typed it out above, all you need to do is copy and paste
2 years ago
okay and now if you click the eye icon, does it show the full url
2 years ago
click the eye icon, not the edit icon
2 years ago
you need to deploy the changes
2 years ago
and have you used that environment variable in code?
2 years ago
have you used that environment variable in code?
2 years ago
let's not do that going forward, please use that environment variable in code
2 years ago
seems like you are overthinking things and it's clouding your judgement, it's just simple steps, one at a time
2 years ago
I had written it out for you here
2 years ago
if you aren't familiar with reading environment variables in code then node has documentation for that
2 years ago
let's see the code please
2 years ago
yep looks good to me
2 years ago
yes, at least when on railway, locally you will need to use the railway cli with railway run
2 years ago
connecting to it from within the private network to avoid egress fees, but I don't know how to explain a solution to that in a simple manner
Hi im trying to test my site locally but i dont know how to do it with out deploying it for everyone to see
2 years ago
you would still connect to the database that runs on railway
2 years ago
what about it??
2 years ago
they automatically get installed on railway during the build process
