First you need to understand that even if your p5js sketch is hosted on a server it is executed on client side, which of course have no access to your server.
To do things you probably imagine you need a way to call s.th. on your server, which usually is done by ie. RestAPI calls to a service (running on your server), which executes code on the server and is called from your p5js sketch and returns the result to your P5 sketch.