Skip to content
DeveloperMemos

How to Fix "Cannot Start Forever Log File x.log Exists" Error

Node.js, forever, logs1 min read

If you're trying to run the forever command and you're seeing the error "Cannot start forever log file x.log exists," it means that the x.log file already exists and forever is unable to write to it. There are a few ways you can fix this issue.

One solution is to simply delete the x.log file. You can do this by running the following command:

1rm x.log

Once you've deleted the file, you should be able to run the forever command without any issues.

Another solution is to specify a different log file when running the forever command. By default, forever will write its logs to a file named forever.log, but you can specify a different file by using the -l option. For example:

1forever -l x.log start my_script.js

Once you've deleted the file, you should be able to run the forever command without any issues.

Another solution is to specify a different log file when running the forever command. By default, forever will write its logs to a file named forever.log, but you can specify a different file by using the -l option. For example:

1forever -l x.log start my_script.js

This will tell forever to write its logs to the x.log file, allowing you to use the same file name as before without encountering any errors.

A third option is to use the -a option when running the forever command. This option tells forever to append its logs to the end of the specified log file instead of overwriting it. For example:

1forever -a -l x.log start my_script.js

This will allow forever to write its logs to the x.log file without causing any errors.

In summary, if you're seeing the "Cannot start forever log file x.log exists" error when trying to run the forever command, you can fix it by either deleting the x.log file, specifying a different log file, or using the -a option to tell forever to append its logs to the end of the file.