Sqlite 3 Invalid ELF header

topcHOBBY

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

topcHOBBY

a year ago

N/A


a year ago

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


topcHOBBY

a year ago

everything is on the github repo


topcHOBBY

a year ago

the modules and db


a year ago

you don't want either to be in github


topcHOBBY

a year ago

ok how can i set it up then


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


topcHOBBY

a year ago

i need to pay for the database??


a year ago

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


topcHOBBY

a year ago

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


a year ago

that's only going to cause headaches unless setup properly


topcHOBBY

a year ago

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


topcHOBBY

a year ago

with the volume and everything


a year ago

like I said, I would highly recommend you use postgres


topcHOBBY

a year ago

ok


topcHOBBY

a year ago

Ngl ima just switch to aws


a year ago

may i ask why?


topcHOBBY

a year ago

More simple


topcHOBBY

a year ago

And I have access to the actual machine


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


topcHOBBY

a year ago

I find it easier to build packages and setup the project through a command line


a year ago

on railway you simply push to github, there's no setup besides adding environment variables


topcHOBBY

a year ago

how do i install the node modules then


a year ago

its done automatically


topcHOBBY

a year ago

its still telling me it has invalid ELF headers


a year ago

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


topcHOBBY

a year ago

no its in the .gitignore


a year ago

that doesnt remove things from the repo


topcHOBBY

a year ago

oh should i just delete it then?


a year ago

yes


topcHOBBY

a year ago

alr


topcHOBBY

a year ago

ok i got it working


topcHOBBY

a year ago

thank you


a year ago

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


topcHOBBY

a year ago

why?


a year ago

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


topcHOBBY

a year ago

oh ok


topcHOBBY

a year ago

and how would it work with postgres?


a year ago

you connect to postgres and use that instead of sqlite


topcHOBBY

a year ago

What’s the benefit in that?


a year ago

you dont have to figure out how volumes works 🤣


topcHOBBY

a year ago

Oh ok


topcHOBBY

a year ago

so my sqlite code will still work?


topcHOBBY

a year ago

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


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


topcHOBBY

a year ago

so i just add a new service in the project?


a year ago

yeah add postgres to the project


topcHOBBY

a year ago

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


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


topcHOBBY

a year ago

Ok sounds good


topcHOBBY

a year ago

You know you’re really getting ripped off here Brody


topcHOBBY

a year ago

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


a year ago

haha thank you


topcHOBBY

a year ago

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


topcHOBBY

a year ago

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


topcHOBBY

a year 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
}


a year ago

that says 127.0.0.1


topcHOBBY

a year ago

ya local host


a year ago

i can assure you that you are not running railway locally


topcHOBBY

a year ago

yes i know


topcHOBBY

a year ago

im trying to run my website localy to test the database


a year ago

you need to connect to postgres on railway


topcHOBBY

a year ago

what do you mean?


topcHOBBY

a year ago

i have set up the database on railway


topcHOBBY

a year ago

do i need to deploy it for it to work


a year ago

and you need to connect to it


topcHOBBY

a year ago

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


topcHOBBY

a year ago

this is how i am


a year ago

bruh


a year ago

asfasfasf ???


topcHOBBY

a year ago

ya im not sending the string here


topcHOBBY

a year ago

i have it tho trust


a year ago

let me know when this is done


topcHOBBY

a year ago

idk it worked when i pushed the changes to the site


a year ago

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


topcHOBBY

a year ago

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


a year ago

it was just adding a variable


topcHOBBY

a year ago

oh i see


topcHOBBY

a year ago

like this?

DATABASEURL ${{Postgres.DATABASEURL}}


a year ago

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


topcHOBBY

a year ago

i did


topcHOBBY

a year ago

sorry that wasnt the rw


topcHOBBY

a year ago

raw


a year ago

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


topcHOBBY

a year ago

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


a year ago

click the eye icon, not the edit icon


topcHOBBY

a year ago

1229285879848243200


a year ago

you need to deploy the changes


topcHOBBY

a year ago

ok


a year ago

and have you used that environment variable in code?


topcHOBBY

a year ago

i put in .env?


a year ago

have you used that environment variable in code?


topcHOBBY

a year ago

no


topcHOBBY

a year ago

i always hardcode everything lol


a year ago

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


topcHOBBY

a year ago

ok ok


topcHOBBY

a year ago

sry im very new to deploying websites


topcHOBBY

a year ago

all bots before this


a year ago

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


topcHOBBY

a year ago

yes


topcHOBBY

a year ago

what should the variable look like in my code


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


topcHOBBY

a year ago

i thought that was for the service only?


topcHOBBY

a year ago

i put the same thing in my code?


a year ago

let's see the code please


topcHOBBY

a year ago

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


topcHOBBY

a year ago

that right?


a year ago

yep looks good to me


topcHOBBY

a year ago

so that will just use the railway variables?


a year ago

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


topcHOBBY

a year ago

ok sounds good


topcHOBBY

a year ago

thank you so much


topcHOBBY

a year ago

also what would i use the database private url for?


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


topcHOBBY

a year ago

ok


topcHOBBY

a year 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


a year ago

you would still connect to the database that runs on railway


topcHOBBY

a year ago

what about the node_modules?


a year ago

what about it??


topcHOBBY

a year ago

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


topcHOBBY

a year ago

Or is their a way to access them from railway


a year ago

they automatically get installed on railway during the build process