Python: Troubleshooting

Encountering an issue with your Python service? The solution is probably here!

👋 Welcome to the Stackhero documentation!

Stackhero provides a ready-to-use Python cloud solution designed to streamline your deployment process:

  • Deploy your application to production in seconds with a simple git push.
  • Use your own domain name, with automatic HTTPS certificate configuration for secure connections handled for you.
  • Rely on automatic backups, one-click updates, and predictable pricing, so you can focus on your code, not infrastructure management.
  • Benefit from strong performance and security on a private, dedicated infrastructure. Your environment is isolated and protected.

Save time and simplify your workflow: you can have your code running with Stackhero's Python cloud hosting in just 5 minutes.

Stackhero's Python cloud hosting service is designed to be straightforward, but occasionally, challenges may arise. Below is a guide to help you address errors you might encounter.

You might encounter this error during application deployment:

error: failed to push some refs to '[...]'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This message indicates that your local Git repository is out of sync with the remote repository on Stackhero. To resolve this, you can override the current state on the remote repository using this command:

git push -f stackhero main

When deploying code using git push stackhero main, you might encounter this error:

error: src refspec main does not match any
error: failed to push some refs to 'ssh://<XXXXXX>.stackhero-network.com:222/project.git'

This error suggests that the main branch does not exist locally. Instead, you might need to push the master branch. You can try this command:

git push stackhero master

Git may display Everything up-to-date when no changes are detected between your local code and the code on Stackhero.

If you have made changes but forgot to commit them, these commands can help:

git add -A .
git commit -m "Your commit message"
git push stackhero main

If no actual changes were made but you still want to trigger a deployment, consider using this approach:

git commit --allow-empty -m "Force update"
git push stackhero main

An enhanced version of the Makefile can automate this process. With this version, you can deploy with a simple make deploy command, even if no code changes are detected.

This error indicates that either a Makefile is missing in the root of your project or the existing Makefile does not define a run target.

To resolve this, you can create a Makefile in your project's root directory with the following example content:

run:
	ENV=production gunicorn app:app \
	--error-logfile - \
	-b 0.0.0.0:8080

This script starts a Gunicorn server, executes the app.py file with the Flask instance app, and listens on port 8080.

Consider using an enhanced Makefile to simplify running your development environment and deploying your application.

The error make: *** missing separator occurs in a Makefile when a tab character is replaced with spaces before a command. Each command in a Makefile must be preceded by a tab character, not spaces.

To fix this error, ensure that a tab character (not spaces) precedes your commands:

run:
<tab>command

Replace <tab> with a real tab character to resolve the issue.