Search code examples
python-3.xpycharmpyramid

corrupt development.ini code


I am working through a python pyramid tutorial, and I have been making as many notes as I can inside the files I am writing.

something strange happened, I'd like to know why.

I wrote the development.ini file like was done in the tutorial then added notes.

# we are using this file for configureation in development

# config our wsgi
[app:main]
# which entry point to use as the app
use = egg:mysite
# reloads when templates are changed, not to be used in production
pyramid.reload_templates = true

#which server to use
[server:main]
#get the main entry point from the waitress package
use = egg:waitress#main
host = 0.0.0.0
port = 6534

# this is a great way to remove code for the rest of our package
# more importantly this file is easy to tweak for launching our package in a different manner

running pserve development.ini chrome returns:

This site can’t be reached

0.0.0.0 refused to connect.
Search Google for 6543
ERR_CONNECTION_REFUSED

I remove the comments:

[app:main]
use = egg:mysite
pyramid.reload_templates = true

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6534

I receive the same error as before.

This site can’t be reached

0.0.0.0 refused to connect.
Search Google for 6543
ERR_CONNECTION_REFUSED

THEN I copy and paste code from the tutorials repo into development.ini:

[app:main]
use = egg:mysite
pyramid.reload_templates = true

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543

I am successfully able to reach localhost.


I am most interested to know, why this happened, how to avoid this problem, and if possible how to comment a development.ini file.

note:

  • I am using PyCharm as my ide
  • I am running this code on my local computer

Solution

  • ERR_CONNECTION_REFUSED means that the port you entered in Chrome's address bar does not align with the port number configuration in your .ini file. Look very carefully at your port numbers to make sure they align. You transposed the 4 and 3 in your original .ini (port = 6534), so I assume you tried to reach http://0.0.0.0:6543 in Chrome's address bar.

    Bonus tip: PyCharm allows you to compare a single file's history on disk as well as version control. This helps reveal typographical errors. Right/CTRL-click on the file, Local History > Show History.