404 errors when attempting to call a function from cli

I cannot seem to get my Netlify functions to work from the cli since I have re-installed my OS

When I try to access a function (to read a faunadb document) I get the error

http://localhost:5000/.netlify/functions/database-access 404 (Not Found)

( I am running on port 5000 because 8888 does not start)

Here is my function (db-acces.js)

const faunadb = require("faunadb");
const index_name = 'all_cars';
const collection_name = 'cars';

const query = faunadb.query;

// the project needs to be 'linked' to a netlify app for the cli version to work
const client = new faunadb.Client({
    secret: process.env.FAUNADB_SECRET_TEST_CARS

exports.handler = async (event) => {
    const context = JSON.parse(event.body);
    const record = {data: context.record};
    const key = context.key
    var query_function
    var record_key = query.Ref(query.Collection(collection_name), key)
    try {
        switch (context.access_type) {
            case 'create':
                query_function = query.Create(record_key, record)

            case 'read':
                query_function = query.Get(record_key)

            case 'update':
                query_function = query.Update(record_key, record)

            case 'delete':
                query_function = query.Delete(record_key)

            case 'read-all':
                query_function = query.Map(
                        query.Lambda((x) => query.Get(x))

        var response = await client.query(query_function)

        return {
            statusCode: 200,
            body: JSON.stringify(response.data),
            headers: {
                "Access-Control-Allow-Origin": "*",
                "Access-Control-Allow-Credentials": true,
    } catch (error) {
        return {
            statusCode: 422,
            body: JSON.stringify(error),

This is my Netlify site, which works as expected


CLI usually runs on :8888. Are you sure yours is running on :5000?

not running on 8888

but on 5000


This is my terminal output
(node:17722) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use node --trace-warnings ... to show where the warning was created)
wasm streaming compile failed: TypeError: Failed to parse URL from /home/jeff/.nvm/versions/node/v18.7.0/lib/node_modules/netlify-cli/node_modules/netlify-redirector/lib/redirects.wasm
falling back to ArrayBuffer instantiation
◈ Netlify Dev ◈
◈ Ignored site settings env var: FAUNADB_SECRET_TEST_CARS (defined in .env file)
◈ Injected .env file env var: FAUNADB_SECRET_TEST_CARS
◈ Ignored general context env var: LANG (defined in process)
◈ Ignored general context env var: LANGUAGE (defined in process)
◈ Loaded function database-access.
◈ Functions server is listening on 38097
◈ Starting Netlify Dev with Svelte

svelte-app@1.0.0 dev
rollup -c -w

rollup v2.73.0
bundles src/main.js → public/build/bundle.js…
LiveReload enabled on port 35732
created public/build/bundle.js in 835ms

svelte-app@1.0.0 start
sirv public --no-clear

Your application is ready~! :rocket:


⠴ Waiting for framework port 5000. This can be configured using the ‘targetPort’ property in the netlify.toml

This is the problem. Add:

  targetPort = 5000

to your netlify.toml.

Thank you, I have tried that but the terminal output remains the same and the problem persists

I have reinstalled my os and have moved to nvm. Could that be an issue?

In that case, this must be the problem:

Yes it was, see my response to