Phil's Notes

EACCES Error with Vue using Vite

vitevue

Depending on your computer set-up, you might see this error when trying to start a Vite project without making any changes to the default template:

Error: listen EACCES: permission denied on 127.0.0.1:3000

For whatever reason, your computer isn't letting you use port 3000. Luckily, the fix is simple enough. You just need to add a line to the vite.config.ts file to specify the port you want to use.

Inside the defineConfig object, add the following line:

server: { port: 8080 }

Of course, you can change 8080 to be whatever port number you have access to. The complete file should look something like this:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
server: { port: 8080 }
})