System Information
- Strapi Version: 4.2.3
- Operating System: macOS Monterey Version 12.2.1
- Database: postgres:14
- Node Version: v14.19.1
- NPM Version: 6.14.16
- Yarn Version:
Good afternoon everyone, I hope someone can help me, I have read all the threads with this problem, nothing has helped me.
I want to run strpi locally, with a local database. And it works every once in a while, and today, after I was creating an entity in the GUI, the process in the terminal crashed, and afterwards I only get An error occurred while requesting the API
Here is my database.js:
const {
DATABASE_CLIENT = ‘postgres’,
DATABASE_NAME = ‘strapi’,
DATABASE_HOST = ‘0.0.0.0’,
DATABASE_PORT = 5432,
DATABASE_USERNAME = ‘strapi’,
DATABASE_PASSWORD = ‘strapi’,
} = process.env
module.exports = () => ({
connection: {
client: DATABASE_CLIENT,
connection: {
host: DATABASE_HOST,
port: DATABASE_PORT,
database: DATABASE_NAME,
user: DATABASE_USERNAME,
password: DATABASE_PASSWORD,
},
useNullAsDefault: true,
},
});
Here is my server.js:
const url = process.argv.filter(e => e === ‘loc’)[0]
module.exports = ({ env }) => ({
url: url ? ‘’ : ‘http://localhost’,
host: env(‘HOST’, ‘0.0.0.0’),
port: env.int(‘PORT’, 1337),
app: {
keys: env.array(‘APP_KEYS’,[
‘DATABASE_CLIENT’,
‘DATABASE_NAME’,
‘DATABASE_HOST’,
‘DATABASE_PORT’,
‘DATABASE_USERNAME’,
‘DATABASE_PASSWORD’,
]),
},
});
Here is my package.json:
{
“name”: “my-project”,
“private”: true,
“version”: “0.1.53”,
“description”: “A Strapi application”,
“scripts”: {
“dev”: “strapi develop loc”,
“start”: “strapi start”,
“build”: “strapi build”,
“interface”: “strapi ts:generate-types”,
“strapi”: “strapi”,
“migration”: “ts-node migration.ts”
},
“devDependencies”: {
“ts-node”: “^10.9.1”
},
“dependencies”: {
“@strapi/plugin-i18n”: “4.2.3”,
“@strapi/plugin-users-permissions”: “4.2.3”,
“@strapi/strapi”: “4.2.3”,
“better-sqlite3”: “7.4.6”,
“lodash”: “^4.17.21”,
“pg”: “^8.7.3”
},
“author”: {
“name”: “A Strapi developer”
},
“strapi”: {
“uuid”: “89d8c5f3-d087-40a9-849d-e1d936382e9c”
},
“engines”: {
“node”: “>=12.x.x <=16.x.x”,
“npm”: “>=6.0.0”
},
“license”: “MIT”
}
Here’s what I do before running it:
- I remove node_modules in strapi
- I delete all docker cache and all possible images
- I remove all npm cache
- I delete the build directory
- I remove the .cache.
- I delete all local database data (i.e. the entire directory so that a new one is created)
- I delete package.json file
Next, I launch:
- npm i
- npm run build
- Docker container with postgres
- npm run dev (“dev”: “strapi develop loc”,)
After that everything is fine, statuses 200 everywhere. A browser tab opens and there is an error: An error occurred while requesting the API