a year 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
a year ago
are you commiting your node_modules to github?
are you storing your sqlite file in a railway volume?
a year ago
you don't want either to be in github
a year ago
remove both from GitHub and then add them to the .gitignore, then change your code to store the sqlite database in a volume
a year ago
but honestly it would likely be far easier if you used postgres
a year ago
yes of course, you'd pay for it's cpu, memory, and disk
a year 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?
a year ago
like I said, I would highly recommend you use postgres
a year ago
may i ask why?
a year ago
interesting answer, it's definitely not simpler, and for this use-case you also definitely don't need access to the machine
a year ago
on railway you simply push to github, there's no setup besides adding environment variables
a year ago
its done automatically
a year ago
are you still including your node_modules folder and sqlite file in github?
a year ago
that doesnt remove things from the repo
a year ago
yes
a year ago
if you arent going to use postgres, make sure your code stores the sqlite file in a volume
a year ago
if you dont store the sqlite file in a volume the data in the sqlite file will not persist between deployments
a year ago
you connect to postgres and use that instead of sqlite
a year ago
you dont have to figure out how volumes works 🤣
a year ago
with postgres? it's not exactly 1:1 compatible
a year ago
don't overthink, you deploy postgres and then have your code connect to it
a year ago
yeah add postgres to the project
a year 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
a year ago
haha thank you
Ok i have modified my code to work with postgres. Where do i find the connection string?
a year 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
a year 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
}
a year ago
that says 127.0.0.1
a year ago
i can assure you that you are not running railway locally
a year ago
you need to connect to postgres on railway
a year ago
and you need to connect to it
const db = new Client({
connectionString: asfasfasf
,
ssl: {
rejectUnauthorized: false,
},
});
db.connect()
a year ago
bruh
a year ago
asfasfasf
???
a year ago
let me know when this is done
a year ago
I don't think I can continue helping if you aren't willing to follow along with my help
a year ago
it was just adding a variable
a year ago
no, I typed it out above, all you need to do is copy and paste
a year ago
okay and now if you click the eye icon, does it show the full url
a year ago
click the eye icon, not the edit icon
a year ago
you need to deploy the changes
a year ago
and have you used that environment variable in code?
a year ago
have you used that environment variable in code?
a year ago
let's not do that going forward, please use that environment variable in code
a year ago
seems like you are overthinking things and it's clouding your judgement, it's just simple steps, one at a time
a year ago
I had written it out for you here
a year ago
if you aren't familiar with reading environment variables in code then node has documentation for that
a year ago
let's see the code please
a year ago
yep looks good to me
a year ago
yes, at least when on railway, locally you will need to use the railway cli with railway run
a year 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
a year ago
you would still connect to the database that runs on railway
a year ago
what about it??
a year ago
they automatically get installed on railway during the build process