Moving to new Server and not able to login

Version ie <v5.11.55> New Server

Version ie <5.11.52> Old Server

Environment

Additional context

I am trying to move my selfhosted invoice ninja 5.11.52 to a new server, and the steps I have taken is as follows:

  • Install php 8.2 and all required extensions
  • Install MySQL DB
  • Mysqldump from the old server and imported to the new server
  • Downloaded the latest invoicenin.tar.gz from github and extracted in my apache
  • changed permissions on the new extracted files
  • configured my apache for the virtual host
  • copied .env and /public/storage from the old server to the new server.
  • updated .env with the new db details
  • I am able to get to the login screen, but cannot login
  • the virtual host has the exact same configuration for the old server with the proper document root and director pointing to /var/www/html/invoiceninja/public

Screenshots

Logs

  • Nothing shows in laravel.log
  • The following appear on the login screen:

Error: please check that Invoice Ninja v5 is installed on the server

URL: https://in.ghf.loc/api/v1/login?first_load=true&include_static=true&einvoice=true

Response:

404 Not Found

Not Found

The requested URL was not found on this server.


Apach

Headers: {connection: Keep-Alive, content-length: 273, content-type: text/html; charset=iso-8859-1, date: Sun, 16 Mar 2025 08:42:02 GMT, keep-alive: timeout=5, max=100, server: Apache/2.4.62 (Debian)}}, you may need to add /public to the URL

NOTE: the server url is changed from the old server but I don’t know if this need to be changed anywhere in the DB.

Hi,

It looks like a local configuration issue but you may want to test with the new web app by running this SQL query:

UPDATE accounts SET set_react_as_default_ap = 1;

I get that error now

still nothing on the invoiceninja logs, but apache logs shows:
POST /api/v1/login HTTP/1.1" 404 835 “https://in.ghf.loc/login” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:136.0) Gecko/20100101 Firefox/136.0”

and browser console shows the following:

TypeError: this is undefined

38 bootstrap-legacy-autofill-overlay.js:6247:9

checkPageContainsShadowDom moz-extension://76602e1f-071b-4a19-9c03-a6c42dfa38fa/content/bootstrap-legacy-autofill-overlay.js:6247

requestIdleCallbackPolyfill moz-extension://76602e1f-071b-4a19-9c03-a6c42dfa38fa/content/bootstrap-legacy-autofill-overlay.js:869

Object { stack: “Qs@https://in.ghf.loc/bundle.BgYYFRRi.js:143:5791\nvVe@https://in.ghf.loc/bundle.BgYYFRRi.js:145:1045\nv@https://in.ghf.loc/bundle.BgYYFRRi.js:145:5726\n”, message: “Request failed with status code 404”, name: “AxiosError”, code: “ERR_BAD_REQUEST”, config: {…}, request: XMLHttpRequest, response: {…}, status: 404 }

bundle.BgYYFRRi.js:419:1472

TypeError: this is undefined5 bootstrap-legacy-autofill-overlay.js:6247:9

All these 404 errors point to a configuration issue, not a problem with the app. Sorry I can’t provide more help, not sure what the issue is. Here’s what ChatGPT suggests:

It looks like Invoice Ninja isn’t able to find the API routes, which suggests an issue with either:

  1. Apache configuration (Rewrite rules)
  2. Application setup (cache, permissions, environment variables)

Troubleshooting Steps

1. Ensure mod_rewrite is enabled

Run the following command to check if Apache’s mod_rewrite is enabled:

sudo a2enmod rewrite
sudo systemctl restart apache2

Then, confirm that your Apache virtual host has the proper AllowOverride directive:

<Directory /var/www/html/invoiceninja/public>
    AllowOverride All
    Require all granted
</Directory>

After making changes, restart Apache:

sudo systemctl restart apache2

2. Check Storage and Bootstrap Permissions

Ensure proper file permissions:

sudo chown -R www-data:www-data /var/www/html/invoiceninja
sudo chmod -R 775 /var/www/html/invoiceninja/storage /var/www/html/invoiceninja/bootstrap/cache

3. Clear Cache and Restart App

Run the following Laravel commands from the Invoice Ninja directory:

php artisan optimize:clear
php artisan migrate --force
php artisan storage:link
php artisan config:clear
php artisan cache:clear
php artisan route:clear

Restart your web server:

sudo systemctl restart apache2

4. Check .env Configuration

Double-check that your .env file has the correct settings:

APP_URL=https://in.ghf.loc
APP_KEY=base64:yourappkeyhere
DB_HOST=your_db_host
DB_DATABASE=your_db_name
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password
QUEUE_CONNECTION=sync

Try running:

php artisan config:cache

5. Check API Routes

Run this command to verify API routes:

php artisan route:list | grep login

If no routes show up, it means the application is not loading correctly.


6. Enable Debug Mode

To see if Laravel is logging any hidden issues, enable debug mode in .env:

APP_DEBUG=true
LOG_CHANNEL=stack

Then check storage/logs/laravel.log:

tail -f storage/logs/laravel.log

Next Steps

  • If mod_rewrite is not working, check Apache logs:
    sudo journalctl -xe | grep apache
    
  • If routes are missing, the application may not have loaded correctly.
  • If the issue persists, try running Invoice Ninja’s self-check:
    php artisan ninja:health-check
    

Let me know what errors you find! :rocket:

Thanks actually i was the rewrite mode, now I am able to login

Glad to hear it, thanks for the update!