Sqlite 3 Invalid ELF header

topc
HOBBYOP

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

topc
HOBBYOP

2 years ago

N/A


2 years ago

are you commiting your node_modules to github?
are you storing your sqlite file in a railway volume?


topc
HOBBYOP

2 years ago

everything is on the github repo


topc
HOBBYOP

2 years ago

the modules and db


2 years ago

you don't want either to be in github


topc
HOBBYOP

2 years ago

ok how can i set it up then


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


topc
HOBBYOP

2 years ago

i need to pay for the database??


2 years ago

yes of course, you'd pay for it's cpu, memory, and disk


topc
HOBBYOP

2 years ago

see im a cheap skate thats why i used github for it


2 years ago

that's only going to cause headaches unless setup properly


topc
HOBBYOP

2 years ago

ok i need to go for now but would you be able to help me set it up some other time?


topc
HOBBYOP

2 years ago

with the volume and everything


2 years ago

like I said, I would highly recommend you use postgres


topc
HOBBYOP

2 years ago

ok


topc
HOBBYOP

2 years ago

Ngl ima just switch to aws


2 years ago

may i ask why?


topc
HOBBYOP

2 years ago

More simple


topc
HOBBYOP

2 years ago

And I have access to the actual machine


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


topc
HOBBYOP

2 years ago

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


topc
HOBBYOP

2 years ago

how do i install the node modules then


2 years ago

its done automatically


topc
HOBBYOP

2 years ago

its still telling me it has invalid ELF headers


2 years ago

are you still including your node_modules folder and sqlite file in github?


topc
HOBBYOP

2 years ago

no its in the .gitignore


2 years ago

that doesnt remove things from the repo


topc
HOBBYOP

2 years ago

oh should i just delete it then?


2 years ago

yes


topc
HOBBYOP

2 years ago

alr


topc
HOBBYOP

2 years ago

ok i got it working


topc
HOBBYOP

2 years ago

thank you


2 years ago

if you arent going to use postgres, make sure your code stores the sqlite file in a volume


topc
HOBBYOP

2 years ago

why?


2 years ago

if you dont store the sqlite file in a volume the data in the sqlite file will not persist between deployments


topc
HOBBYOP

2 years ago

oh ok


topc
HOBBYOP

2 years ago

and how would it work with postgres?


2 years ago

you connect to postgres and use that instead of sqlite


topc
HOBBYOP

2 years ago

What’s the benefit in that?


2 years ago

you dont have to figure out how volumes works 🤣


topc
HOBBYOP

2 years ago

Oh ok


topc
HOBBYOP

2 years ago

so my sqlite code will still work?


topc
HOBBYOP

2 years ago

and what do i need to do to get it set up


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


topc
HOBBYOP

2 years ago

so i just add a new service in the project?


2 years ago

yeah add postgres to the project


topc
HOBBYOP

2 years ago

ok how do i connect to it in my code now?


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


topc
HOBBYOP

2 years ago

Ok sounds good


topc
HOBBYOP

2 years ago

You know you’re really getting ripped off here Brody


topc
HOBBYOP

2 years ago

Railway should be paying you for dealing with people like me all day


2 years ago

haha thank you


topc
HOBBYOP

2 years ago

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


topc
HOBBYOP

2 years ago

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


topc
HOBBYOP

2 years ago

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


topc
HOBBYOP

2 years ago

ya local host


2 years ago

i can assure you that you are not running railway locally


topc
HOBBYOP

2 years ago

yes i know


topc
HOBBYOP

2 years ago

im trying to run my website localy to test the database


2 years ago

you need to connect to postgres on railway


topc
HOBBYOP

2 years ago

what do you mean?


topc
HOBBYOP

2 years ago

i have set up the database on railway


topc
HOBBYOP

2 years ago

do i need to deploy it for it to work


2 years ago

and you need to connect to it


topc
HOBBYOP

2 years ago

const db = new Client({
connectionString: asfasfasf,
ssl: {
rejectUnauthorized: false,
},
});
db.connect()


topc
HOBBYOP

2 years ago

this is how i am


2 years ago

bruh


2 years ago

asfasfasf ???


topc
HOBBYOP

2 years ago

ya im not sending the string here


topc
HOBBYOP

2 years ago

i have it tho trust


2 years ago

let me know when this is done


topc
HOBBYOP

2 years ago

idk it worked when i pushed the changes to the site


2 years ago

I don't think I can continue helping if you aren't willing to follow along with my help


topc
HOBBYOP

2 years ago

i am willing i just dont understand railway enough to do some things


2 years ago

it was just adding a variable


topc
HOBBYOP

2 years ago

oh i see


topc
HOBBYOP

2 years ago

like this?

DATABASEURL ${{Postgres.DATABASEURL}}


2 years ago

no, I typed it out above, all you need to do is copy and paste


topc
HOBBYOP

2 years ago

i did


topc
HOBBYOP

2 years ago

sorry that wasnt the rw


topc
HOBBYOP

2 years ago

raw


2 years ago

okay and now if you click the eye icon, does it show the full url


topc
HOBBYOP

2 years ago

no it just says shows this: ${{Postgres.DATABASE_URL}}


2 years ago

click the eye icon, not the edit icon


topc
HOBBYOP

2 years ago

1229285879848243200


2 years ago

you need to deploy the changes


topc
HOBBYOP

2 years ago

ok


2 years ago

and have you used that environment variable in code?


topc
HOBBYOP

2 years ago

i put in .env?


2 years ago

have you used that environment variable in code?


topc
HOBBYOP

2 years ago

no


topc
HOBBYOP

2 years ago

i always hardcode everything lol


2 years ago

let's not do that going forward, please use that environment variable in code


topc
HOBBYOP

2 years ago

ok ok


topc
HOBBYOP

2 years ago

sry im very new to deploying websites


topc
HOBBYOP

2 years ago

all bots before this


2 years ago

seems like you are overthinking things and it's clouding your judgement, it's just simple steps, one at a time


topc
HOBBYOP

2 years ago

yes


topc
HOBBYOP

2 years ago

what should the variable look like in my code


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


topc
HOBBYOP

2 years ago

i thought that was for the service only?


topc
HOBBYOP

2 years ago

i put the same thing in my code?


2 years ago

let's see the code please


topc
HOBBYOP

2 years ago

const db = new Client({
connectionString: process.env.DATABASE_URL,
});


topc
HOBBYOP

2 years ago

that right?


2 years ago

yep looks good to me


topc
HOBBYOP

2 years ago

so that will just use the railway variables?


2 years ago

yes, at least when on railway, locally you will need to use the railway cli with railway run


topc
HOBBYOP

2 years ago

ok sounds good


topc
HOBBYOP

2 years ago

thank you so much


topc
HOBBYOP

2 years ago

also what would i use the database private url for?


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


topc
HOBBYOP

2 years ago

ok


topc
HOBBYOP

2 years ago

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


topc
HOBBYOP

2 years ago

what about the node_modules?


2 years ago

what about it??


topc
HOBBYOP

2 years ago

Do I need to reinstall them when I’m testing??


topc
HOBBYOP

2 years ago

Or is their a way to access them from railway


2 years ago

they automatically get installed on railway during the build process